Skip to content

Commit

Permalink
fix dry run
Browse files Browse the repository at this point in the history
  • Loading branch information
reallistic committed Nov 18, 2014
1 parent 03e24ab commit 27d71ab
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions BitcasaFileFetcher/threads/folder_traverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def folder_list_gdrive(folder, status, results, args, should_exit, g):
folderitems = get_folder_items(fold, should_exit)
if folderitems is None:
log.error("Error downloading at folder %s", path)
if args.local:
if not args.local:
results.writeError(folder["folder"].name, path, folder_id, "")
else:
results.writeError(folder["folder"].name, path, folder["folder"].path, "")
Expand All @@ -152,7 +152,10 @@ def folder_list_gdrive(folder, status, results, args, should_exit, g):
apiratecount = 1
while not should_exit.is_set() and retriesleft > 0:
try:
needtoupload = g.need_to_upload(nm, folder_id, filesize)
if args.dryrun and not folder_id:
needtoupload = True
else:
needtoupload = g.need_to_upload(nm, folder_id, filesize)
except HttpError as e:
retriesleft -= 1
if e.resp.status == 403:
Expand Down Expand Up @@ -193,12 +196,12 @@ def folder_list_gdrive(folder, status, results, args, should_exit, g):
}
if args.local:
if not args.silentqueuer:
log.debug("Queuing file download for %s", nm)
log.debug("Queuing file upload for %s", nm)
filedownload["temppath"] = base64_path
status.queue_up(filedownload)
else:
if not args.silentqueuer:
log.debug("Queuing file upload for %s", nm)
log.debug("Queuing file download for %s", nm)
status.queue_down(filedownload)
else:
results.writeSkipped(tfd, base64_path, nm)
Expand All @@ -214,7 +217,10 @@ def folder_list_gdrive(folder, status, results, args, should_exit, g):
apiratecount = 1
while not should_exit.is_set() and retriesleft > 0:
try:
g_fold = g.get_folder_byname(nm, parent=folder_id, createnotfound=True)
if args.dryrun and not folder_id:
g_fold = False
else:
g_fold = g.get_folder_byname(nm, parent=folder_id, createnotfound=cnf)
except HttpError as e:
retriesleft -= 1
if e.resp.status == 403:
Expand Down Expand Up @@ -243,14 +249,20 @@ def folder_list_gdrive(folder, status, results, args, should_exit, g):
if should_exit.is_set():
log.debug("Stopping folder list")
return
if not args.silentqueuer:
log.debug("Queuing folder listing for %s", nm)
folder = {
"folder": item,
"depth": (depth+1),
"path": tfd,
"folder_id": g_fold["id"]
"path": tfd
}
if args.dryrun and not g_fold:
folder["folder_id"] = None
elif not g_fold:
results.writeError(nm, tfd, base64_path, "Failed to get/create folder %s" % nm)
continue
else:
folder["folder_id"] = g_fold["id"]
if not args.silentqueuer:
log.debug("Queuing folder listing for %s", nm)
status.queue(folder)
except:
results.writeError(nm, tfd, base64_path, traceback.format_exc())
Expand Down

1 comment on commit 27d71ab

@reallistic
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes #68

Please sign in to comment.