Merge branch 'check_is_valid_file' of https://github.com/mig5/onionshare into mig5-check_is_valid_file

This commit is contained in:
Micah Lee 2018-01-14 18:54:48 -08:00
commit 808c4cfac2
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
3 changed files with 9 additions and 5 deletions

View File

@ -68,7 +68,7 @@ def main(cwd=None):
# Validation # Validation
valid = True valid = True
for filename in filenames: for filename in filenames:
if not os.path.exists(filename): if not os.path.isfile(filename) and not os.path.isdir(filename):
print(strings._("not_a_file").format(filename)) print(strings._("not_a_file").format(filename))
valid = False valid = False
if not os.access(filename, os.R_OK): if not os.access(filename, os.R_OK):
@ -102,8 +102,12 @@ def main(cwd=None):
# Prepare files to share # Prepare files to share
print(strings._("preparing_files")) print(strings._("preparing_files"))
web.set_file_info(filenames) try:
app.cleanup_filenames.append(web.zip_filename) web.set_file_info(filenames)
app.cleanup_filenames.append(web.zip_filename)
except OSError as e:
print(e.strerror)
sys.exit(1)
# Warn about sending large files over Tor # Warn about sending large files over Tor
if web.zip_filesize >= 157286400: # 150mb if web.zip_filesize >= 157286400: # 150mb

View File

@ -91,7 +91,7 @@ def main():
if filenames: if filenames:
valid = True valid = True
for filename in filenames: for filename in filenames:
if not os.path.exists(filename): if not os.path.isfile(filename) and not os.path.isdir(filename):
Alert(strings._("not_a_file", True).format(filename)) Alert(strings._("not_a_file", True).format(filename))
valid = False valid = False
if not os.access(filename, os.R_OK): if not os.access(filename, os.R_OK):

View File

@ -8,7 +8,7 @@
"give_this_url": "Give this URL to the person you're sending the file to:", "give_this_url": "Give this URL to the person you're sending the file to:",
"give_this_url_stealth": "Give this URL and HidServAuth line to the person you're sending the file to:", "give_this_url_stealth": "Give this URL and HidServAuth line to the person you're sending the file to:",
"ctrlc_to_stop": "Press Ctrl-C to stop server", "ctrlc_to_stop": "Press Ctrl-C to stop server",
"not_a_file": "{0:s} is not a file.", "not_a_file": "{0:s} is not a valid file.",
"not_a_readable_file": "{0:s} is not a readable file.", "not_a_readable_file": "{0:s} is not a readable file.",
"no_available_port": "Could not start the Onion service as there was no available port.", "no_available_port": "Could not start the Onion service as there was no available port.",
"download_page_loaded": "Download page loaded", "download_page_loaded": "Download page loaded",