Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Make progress file path respect --config-dir parameter #717

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions bypy/bypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ def __init__(self,
self._configdir = configdir.rstrip("/\\ ")
makedir(self._configdir)
# os.path.join() may not handle unicode well on Python 2.7
self._progresspath = configdir + os.sep + const.ProgressFileName
self._tokenpath = configdir + os.sep + const.TokenFileName
self._settingpath = configdir + os.sep + const.SettingFileName
self._setting = {}
Expand Down Expand Up @@ -1562,26 +1563,26 @@ def _update_progress_entry(self, fullpath):
progress = {}

try:
progress = jsonload(const.ProgressPath)
progress = jsonload(self._progresspath)
except Exception as ex:
perr("Error loading the progress for: '{}'.\n{}.".format(fullpath, formatex(ex)))

self.pd("Updating slice upload progress for {}".format(fullpath))
progress[fullpath] = (self._slice_size, self._slice_md5s)

try:
jsondump(progress, const.ProgressPath, mpsemaphore)
jsondump(progress, self._progresspath, mpsemaphore)
except Exception as ex:
perr("Error updating the progress for: '{}'.\n{}.".format(fullpath, formatex(ex)))

def _delete_progress_entry(self, fullpath):
try:
progress = jsonload(const.ProgressPath)
progress = jsonload(self._progresspath)
# http://stackoverflow.com/questions/11277432/how-to-remove-a-key-from-a-python-dictionary
#del progress[fullpath]
self.pd("Removing slice upload progress for {}".format(fullpath))
progress.pop(fullpath, None)
jsondump(progress, const.ProgressPath, mpsemaphore)
jsondump(progress, self._progresspath, mpsemaphore)
except Exception as ex:
perr("Error deleting the progress for: '{}'.\n{}.".format(fullpath, formatex(ex)))

Expand All @@ -1607,14 +1608,14 @@ def _upload_file_slices(self, localpath, remotepath, ondup = 'overwrite'):
progress = {}
initial_offset = 0
# create an empty progress file first
if not os.path.exists(const.ProgressPath):
if not os.path.exists(self._progresspath):
try:
jsondump(progress, const.ProgressPath, mpsemaphore)
jsondump(progress, self._progresspath, mpsemaphore)
except Exception as ex:
perr("Error savingprogress, no resumption.\n{}".format(formatex(ex)))

try:
progress = jsonload(const.ProgressPath)
progress = jsonload(self._progresspath)
except Exception as ex:
perr("Error loading progress, no resumption.\n{}".format(formatex(ex)))

Expand Down