|
@ -168,10 +168,10 @@ def restore_file(packed): |
|
|
for i in range(0, len(keys)): |
|
|
for i in range(0, len(keys)): |
|
|
if content_equal(original, arguments.server + fixed_versions[keys[i]]['path'], auth): |
|
|
if content_equal(original, arguments.server + fixed_versions[keys[i]]['path'], auth): |
|
|
# found latest matching version |
|
|
# found latest matching version |
|
|
# print("Restore from {}".format(fixed_versions)) |
|
|
|
|
|
restored = restore_by_version(arguments.server + fixed_versions['path'], auth, arguments) |
|
|
|
|
|
|
|
|
# print("Restore from {}".format(fixed_versions[keys[i]])) |
|
|
|
|
|
restored = restore_by_version(arguments.server + fixed_versions[keys[i]]['path'], auth, arguments) |
|
|
break # stop looking any further |
|
|
break # stop looking any further |
|
|
else: |
|
|
|
|
|
|
|
|
if not restored: |
|
|
# print("Touch file.") |
|
|
# print("Touch file.") |
|
|
restored = restore_by_touch(arguments.server + entry['path'], original, auth) |
|
|
restored = restore_by_touch(arguments.server + entry['path'], original, auth) |
|
|
if not restored: |
|
|
if not restored: |
|
@ -179,7 +179,6 @@ def restore_file(packed): |
|
|
os.remove(original) |
|
|
os.remove(original) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def restore_by_version(path_version, auth, args): |
|
|
def restore_by_version(path_version, auth, args): |
|
|
""" |
|
|
""" |
|
|
Restores the given old version of a file |
|
|
Restores the given old version of a file |
|
@ -189,7 +188,7 @@ def restore_by_version(path_version, auth, args): |
|
|
:return: True if the version was successfully restored, false otherwise |
|
|
:return: True if the version was successfully restored, false otherwise |
|
|
""" |
|
|
""" |
|
|
# uuid4 should create a random uuid |
|
|
# uuid4 should create a random uuid |
|
|
headers = {"Destination": args.server + VERSIONS_PATH_PREFIX + arguments.username + "/restore/" + uuid.uuid4()} |
|
|
|
|
|
|
|
|
headers = {"Destination": args.server + VERSIONS_PATH_PREFIX + args.username + "/restore/" + str(uuid.uuid4())} |
|
|
r = requests.request( |
|
|
r = requests.request( |
|
|
method='move', |
|
|
method='move', |
|
|
url=path_version, |
|
|
url=path_version, |
|
@ -239,7 +238,7 @@ if __name__ == "__main__": |
|
|
# Iterate through all folders and check for wrong timestamps |
|
|
# Iterate through all folders and check for wrong timestamps |
|
|
url = arguments.server + mainpath |
|
|
url = arguments.server + mainpath |
|
|
for entry in propfind(url, auth): |
|
|
for entry in propfind(url, auth): |
|
|
if "last_modified" in entry and entry["last_modified"] < DATE_THRESHOLD: |
|
|
|
|
|
|
|
|
if "last_modified" not in entry or entry["last_modified"] < DATE_THRESHOLD: |
|
|
wrongtime.append(entry) |
|
|
wrongtime.append(entry) |
|
|
|
|
|
|
|
|
print() |
|
|
print() |
|
|