Compare commits
4 Commits
e826c31048
...
cc40df65d3
Author | SHA1 | Date |
---|---|---|
BodgeMaster | cc40df65d3 | |
BodgeMaster | b5c9d92ca8 | |
BodgeMaster | b9dc47d0e9 | |
BodgeMaster | d4fed7aee4 |
7
LICENSE
7
LICENSE
|
@ -10,7 +10,12 @@ 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. Don't be a dick.
|
||||
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.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
|
|
50
filetags.py
50
filetags.py
|
@ -200,6 +200,8 @@ 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("+")
|
||||
|
@ -212,11 +214,6 @@ 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":
|
||||
|
@ -349,7 +346,6 @@ 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)
|
||||
|
@ -401,6 +397,48 @@ 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
|
||||
|
|
Loading…
Reference in New Issue