Compare commits

..

No commits in common. "cc40df65d30a59979ca8cc36613135db2f1b3b67" and "e826c31048b9be65563f230aa87a8cfaeebe94c7" have entirely different histories.

2 changed files with 7 additions and 50 deletions

View File

@ -10,12 +10,7 @@ this list of conditions and the following disclaimer.
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software must
clearly acknowledge that this software is being used unless software from more
than two other projects and/or vendors is being included in the distribution of
the advertised product.
4. Don't be an asshole.
3. Don't be a dick.
THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF

View File

@ -200,8 +200,6 @@ if __name__ == "__main__":
#TODO: clarification of <> and []
#TODO: subcommand to change container settings
VALID_COMMANDS=["create", "add", "remove", "search", "lookup", "link", "check", "update", "fix", "help"]
#TODO: (*fully) implemented subcommands: *create, *add, *lookup, *link, *help
#TODO: unimplemented subcommands: remove, search, check, update, fix
try:
command = sys.argv[1].split("+")
@ -214,6 +212,11 @@ if __name__ == "__main__":
print(USAGE, file=sys.stderr)
sys.exit(USAGE_ERROR)
# help subcommand
if command[0] == "help":
print(USAGE)
sys.exit(0)
# create subcommand: create a new directory containing a folder for stored objects, one for parity files and one for
# arguments: <storage directory> [parity=<on|off>] [parity-bytes=<number of bytes for each parity byte>] [checksum-algorithm=<algorithm>] [compress=<on|off>]
if command[0] == "create":
@ -346,6 +349,7 @@ if __name__ == "__main__":
# unique - return error if not found or multiple found
# hash - perform lookup by hash
# tags - perform lookup by tag or set of tags
#TODO: modifiers: first unique
if command[0] == "lookup":
if len(sys.argv)<4:
print("Too few arguments!", file=sys.stderr)
@ -397,48 +401,6 @@ if __name__ == "__main__":
else:
print(json.dumps(lookup_results))
# link subcommand: add a symlink in <location> that points to the referenced file
# arguments:
# <storage directory> <hash> <location>
if command[0] == "link":
if len(sys.argv)<5:
print("Too few arguments!", file=sys.stderr)
print(USAGE, file=sys.stderr)
sys.exit(USAGE_ERROR)
storage_directory = sys.argv[2]
file_hash = sys.argv[3]
link_location = sys.argv[4]
status, parity, parity_bytes, checksum_algorithm, compress = load_container_settings(storage_directory)
if not status==0:
if status==PATH_ERROR:
print("Invalid storage directory!", file=sys.stderr)
print(USAGE, file=sys.stderr)
if status==GENERAL_ERROR:
print("Verifying container settings failed.", file=sys.stderr)
sys.exit(status)
if file_hash_or_path_is_known_hash(storage_directory, file_hash, compress):
if os.path.isdir(os.sep.join(link_location.split(os.sep)[:-1])):
if os.path.exists(link_location):
print(link_location+": file already exists.", file=sys.stderr)
sys.exit(GENERAL_ERROR)
else:
suffix = ""
if compress:
suffix = ".xz"
object_path = os.path.join(storage_directory, "objects", file_hash+suffix)
os.symlink(object_path, link_location)
print(link_location+" -> "+object_path)
else:
print("Parent directory "+os.sep.join(link_location.split(os.sep)[:-1])+" does not exist.", file=sys.stderr)
sys.exit(GENERAL_ERROR)
# help subcommand
if command[0] == "help":
print(USAGE)
sys.exit(0)
# this line is here to work around a bug in Xed