diff --git a/fix_dates.py b/fix_dates.py index 6e6a4bf..3a321e6 100644 --- a/fix_dates.py +++ b/fix_dates.py @@ -168,10 +168,10 @@ def restore_file(packed): for i in range(0, len(keys)): if content_equal(original, arguments.server + fixed_versions[keys[i]]['path'], auth): # 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 - else: + if not restored: # print("Touch file.") restored = restore_by_touch(arguments.server + entry['path'], original, auth) if not restored: @@ -179,7 +179,6 @@ def restore_file(packed): os.remove(original) - def restore_by_version(path_version, auth, args): """ 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 """ # 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( method='move', url=path_version, @@ -239,7 +238,7 @@ if __name__ == "__main__": # Iterate through all folders and check for wrong timestamps url = arguments.server + mainpath 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) print()