commands write with the same switch

This commit is contained in:
Ville Rantanen
2018-02-18 17:28:51 +02:00
parent f16ec3eeb4
commit 7dce698bae
3 changed files with 22 additions and 20 deletions

View File

@@ -22,7 +22,7 @@ The name comes from mispronouncing "files" very badly.
- workers = parallel processes (i.e. one upload reserves a process) - workers = parallel processes (i.e. one upload reserves a process)
- timeout = timeout for processes, single upload might take a long time! - timeout = timeout for processes, single upload might take a long time!
- configure bind host and port in .env - configure bind host and port in .env
- proxy with nginx: - proxy with nginx, match body size and timeout to your needs:
``` ```
location /flees/ { location /flees/ {
proxy_pass http://localhost:8136/; proxy_pass http://localhost:8136/;
@@ -31,6 +31,7 @@ location /flees/ {
proxy_set_header X-Scheme $scheme; proxy_set_header X-Scheme $scheme;
proxy_set_header X-Script-Name /flees; proxy_set_header X-Script-Name /flees;
client_max_body_size 8G; client_max_body_size 8G;
client_body_timeout 240s;
} }
``` ```

View File

@@ -59,6 +59,7 @@ function UploadFile(file,file_no,files_total) {
xhr.setRequestHeader("X-FILENAME", file.name); xhr.setRequestHeader("X-FILENAME", file.name);
var formData = new FormData(); var formData = new FormData();
formData.append('name', document.getElementById("list_upload_name").value); formData.append('name', document.getElementById("list_upload_name").value);
formData.append('from_gui', 'true');
formData.append('file', file); formData.append('file', file);
xhr.send(formData); xhr.send(formData);

View File

@@ -139,7 +139,7 @@ def add_share(shares, config, opts):
'expire': opts.expire 'expire': opts.expire
}) })
if opts.insert: if opts.write:
shares.append(share) shares.append(share)
shares_file = os.path.join(config['__root_path__'], opts.shares_file) shares_file = os.path.join(config['__root_path__'], opts.shares_file)
if os.path.exists(shares_file): if os.path.exists(shares_file):
@@ -153,7 +153,7 @@ def add_share(shares, config, opts):
print("Wrote file %s"%(shares_file,)) print("Wrote file %s"%(shares_file,))
print("Add share: %s"%( opts.name, )) print("Add share: %s"%( opts.name, ))
else: else:
print("Share not saved anywhere. Save with -i") print("Share not saved anywhere. Save with -w")
print(json.dumps(share, indent = 2, sort_keys = True)) print(json.dumps(share, indent = 2, sort_keys = True))
@@ -206,7 +206,7 @@ def modify_share(shares, config, opts):
sys.exit(1) sys.exit(1)
share['expire'] = opts.expire share['expire'] = opts.expire
if opts.insert: if opts.write:
shares[i] = share shares[i] = share
shares_file = os.path.join(config['__root_path__'], opts.shares_file) shares_file = os.path.join(config['__root_path__'], opts.shares_file)
if os.path.exists(shares_file): if os.path.exists(shares_file):
@@ -219,7 +219,7 @@ def modify_share(shares, config, opts):
json.dump(shares, fp, indent = 2, sort_keys = True) json.dump(shares, fp, indent = 2, sort_keys = True)
print("Wrote file %s"%(shares_file,)) print("Wrote file %s"%(shares_file,))
else: else:
print("Share not saved anywhere. Save with -i") print("Share not saved anywhere. Save with -w")
modified = [] modified = []
for key in share: for key in share:
if not key in orig_share: if not key in orig_share:
@@ -399,33 +399,33 @@ def parse_options():
parser_add.add_argument('-e','--expire', action="store", dest="expire", default = False, parser_add.add_argument('-e','--expire', action="store", dest="expire", default = False,
help = "expire date in format '%%Y-%%m-%%d %%H:%%M' ex. '2018-12-24 21:00'" help = "expire date in format '%%Y-%%m-%%d %%H:%%M' ex. '2018-12-24 21:00'"
) )
parser_add.add_argument('-i','--insert', action="store_true", dest="insert", default = False, parser_add.add_argument('-w','--write', action="store_true", dest="write", default = False,
help = "Insert new share directly in the shares.json file" help = "Write changes to the shares.json file"
) )
## Modify ## Modify
parser_add = subparsers.add_parser('modify', help = "Modify share") parser_modify = subparsers.add_parser('modify', help = "Modify share")
parser_add.add_argument('-n','--name', action="store", dest="name", required = True) parser_modify.add_argument('-n','--name', action="store", dest="name", required = True)
parser_add.add_argument('-p','--path', action="store", dest="path", default = None, parser_modify.add_argument('-p','--path', action="store", dest="path", default = None,
help= "path relative to data folder" help= "path relative to data folder"
) )
parser_add.add_argument('-D','--description', action="store", dest="description", default = None, parser_modify.add_argument('-D','--description', action="store", dest="description", default = None,
help= "Describe the contents" help= "Describe the contents"
) )
parser_add.add_argument('-P','--public', action="store", dest="public", default = None, choices = ['true','false']) parser_modify.add_argument('-P','--public', action="store", dest="public", default = None, choices = ['true','false'])
parser_add.add_argument('-u','--upload', action="store", dest="upload", default = None, choices = ['true','false']) parser_modify.add_argument('-u','--upload', action="store", dest="upload", default = None, choices = ['true','false'])
parser_add.add_argument('-o','--overwrite', action="store", dest="overwrite", default = None, choices = ['true','false'], parser_modify.add_argument('-o','--overwrite', action="store", dest="overwrite", default = None, choices = ['true','false'],
help = "Disable file overwrites") help = "Disable file overwrites")
parser_add.add_argument('-d','--direct', action="store", dest="direct_links", default = None, choices = ['true','false'], parser_modify.add_argument('-d','--direct', action="store", dest="direct_links", default = None, choices = ['true','false'],
help = "Allow direct file sharing (password hash included in URL)") help = "Allow direct file sharing (password hash included in URL)")
parser_add.add_argument('--pass-plain', action="store_true", dest="plain", default = False, parser_modify.add_argument('--pass-plain', action="store_true", dest="plain", default = False,
help = "Save the password as plain text") help = "Save the password as plain text")
parser_add.add_argument('--password', action="store", dest="password", default = False, parser_modify.add_argument('--password', action="store", dest="password", default = False,
help = "Setting a password enables use of login links and direct downloads. Set as empty string to remove password protection.") help = "Setting a password enables use of login links and direct downloads. Set as empty string to remove password protection.")
parser_add.add_argument('-e','--expire', action="store", dest="expire", default = False, parser_modify.add_argument('-e','--expire', action="store", dest="expire", default = False,
help = "expire date in format '%%Y-%%m-%%d %%H:%%M' ex. '2018-12-24 21:00'. Set as empty string to remove expiration." help = "expire date in format '%%Y-%%m-%%d %%H:%%M' ex. '2018-12-24 21:00'. Set as empty string to remove expiration."
) )
parser_add.add_argument('-i','--insert', action="store_true", dest="insert", default = False, parser_modify.add_argument('-w','--write', action="store_true", dest="write", default = False,
help = "Insert new share directly in the shares.json file" help = "Write changes to the shares.json file"
) )
## REST ## REST
parser_rest = subparsers.add_parser('rest', help = "Display REST API links") parser_rest = subparsers.add_parser('rest', help = "Display REST API links")