Skip to content

Commit

Permalink
Merge pull request #14 from qbicsoftware/fix/dm-636-folder-cleanup-error
Browse files Browse the repository at this point in the history
add method to retry deletion of tmp folder to fix #13
  • Loading branch information
wow-such-code authored Dec 2, 2022
2 parents 7c44c7f + 3992ffe commit 12f3b82
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion dropboxhandler/fstools.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,17 @@ def check_permissions(path, userid, groupid, dirmode, filemode):
userid, groupid, dirmode, filemode)


def wait_and_retry(redo_func, path, err):
"""Retries the same function on the same path after 10 seconds of wait time.
Used to fix issues with deleting tmp folders containing many large datasets.
"""
logger.debug("Error calling "+redo_func.__name__)
logger.debug("On path "+str(path))
logger.debug("Sleeping 10 seconds and trying again.")
time.sleep(10)
redo_func(path)


def recursive_copy(source, dest, tmpdir=None, perms=None, link=False):
"""Copy a file or directory to destination.
Expand Down Expand Up @@ -246,4 +257,4 @@ def recursive_copy(source, dest, tmpdir=None, perms=None, link=False):
shutil.rmtree(dest)
raise
finally:
shutil.rmtree(tmpdir)
shutil.rmtree(tmpdir, onerror = wait_and_retry)

0 comments on commit 12f3b82

Please sign in to comment.