mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-25 02:32:58 -03:00
Added optional filename logging for individual file downloads
This commit is contained in:
parent
8102c15376
commit
4128cad08f
3 changed files with 25 additions and 2 deletions
|
@ -119,6 +119,13 @@ def main(cwd=None):
|
||||||
default=False,
|
default=False,
|
||||||
help="Share files: Continue sharing after files have been sent (default is to stop sharing)",
|
help="Share files: Continue sharing after files have been sent (default is to stop sharing)",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--log-filenames",
|
||||||
|
action="store_true",
|
||||||
|
dest="log_filenames",
|
||||||
|
default=False,
|
||||||
|
help="Share files: Log individual names of shared files as they are downloaded (requires autostop sharing to be disabled)"
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--qr",
|
"--qr",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
|
@ -204,6 +211,7 @@ def main(cwd=None):
|
||||||
disable_files = args.disable_files
|
disable_files = args.disable_files
|
||||||
disable_csp = bool(args.disable_csp)
|
disable_csp = bool(args.disable_csp)
|
||||||
custom_csp = args.custom_csp
|
custom_csp = args.custom_csp
|
||||||
|
log_filenames = bool(args.log_filenames)
|
||||||
verbose = bool(args.verbose)
|
verbose = bool(args.verbose)
|
||||||
|
|
||||||
# Verbose mode?
|
# Verbose mode?
|
||||||
|
@ -242,6 +250,7 @@ def main(cwd=None):
|
||||||
mode_settings.set("persistent", "mode", mode)
|
mode_settings.set("persistent", "mode", mode)
|
||||||
if mode == "share":
|
if mode == "share":
|
||||||
mode_settings.set("share", "autostop_sharing", autostop_sharing)
|
mode_settings.set("share", "autostop_sharing", autostop_sharing)
|
||||||
|
mode_settings.set("share", "log_filenames", log_filenames)
|
||||||
if mode == "receive":
|
if mode == "receive":
|
||||||
if data_dir:
|
if data_dir:
|
||||||
mode_settings.set("receive", "data_dir", data_dir)
|
mode_settings.set("receive", "data_dir", data_dir)
|
||||||
|
@ -299,6 +308,10 @@ def main(cwd=None):
|
||||||
if persistent_filename:
|
if persistent_filename:
|
||||||
mode_settings.set(mode, "filenames", filenames)
|
mode_settings.set(mode, "filenames", filenames)
|
||||||
|
|
||||||
|
if autostop_sharing and log_filenames:
|
||||||
|
print("Autostop sharing is enabled, thus individual files cannot be downloaded (or logged). Set both --no-autostop-sharing and --log-filenames for intended functionality.")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
# In receive mode, you must allows either text, files, or both
|
# In receive mode, you must allows either text, files, or both
|
||||||
if mode == "receive" and disable_text and disable_files:
|
if mode == "receive" and disable_text and disable_files:
|
||||||
print("You cannot disable both text and files")
|
print("You cannot disable both text and files")
|
||||||
|
|
|
@ -48,7 +48,11 @@ class ModeSettings:
|
||||||
"autostop_timer": False,
|
"autostop_timer": False,
|
||||||
"service_id": None,
|
"service_id": None,
|
||||||
},
|
},
|
||||||
"share": {"autostop_sharing": True, "filenames": []},
|
"share": {
|
||||||
|
"autostop_sharing": True,
|
||||||
|
"filenames": [],
|
||||||
|
"log_filenames": False,
|
||||||
|
},
|
||||||
"receive": {
|
"receive": {
|
||||||
"data_dir": self.build_default_receive_data_dir(),
|
"data_dir": self.build_default_receive_data_dir(),
|
||||||
"webhook_url": None,
|
"webhook_url": None,
|
||||||
|
|
|
@ -245,8 +245,14 @@ class SendBaseModeWeb:
|
||||||
or self.common.platform == "Linux"
|
or self.common.platform == "Linux"
|
||||||
or self.common.platform == "BSD"
|
or self.common.platform == "BSD"
|
||||||
):
|
):
|
||||||
|
if self.web.settings.get("share", "log_filenames"):
|
||||||
|
filename_str = "{0} - ".format(os.path.basename(file_to_download))
|
||||||
|
else:
|
||||||
|
filename_str = ""
|
||||||
|
|
||||||
sys.stdout.write(
|
sys.stdout.write(
|
||||||
"\r{0:s}, {1:.2f}% ".format(
|
"\r{0}{1:s}, {2:.2f}% ".format(
|
||||||
|
filename_str,
|
||||||
self.common.human_readable_filesize(
|
self.common.human_readable_filesize(
|
||||||
downloaded_bytes
|
downloaded_bytes
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Reference in a new issue