Commits

mickael9 committed 4bd707e

Added an option to upload files sequentially

  • Participants
  • Parent commits f569cd3

Comments (0)

Files changed (1)

 parser.add_argument('-t', dest='title', help='Title of the share (defaults to first file name)')
 parser.add_argument('-s', dest='share', help='Name of the share to upload to (defaults to a newly created one)')
 parser.add_argument('-D', dest='debug', action='store_true', help='Debug API calls')
+parser.add_argument('-S', dest='seq', action='store_true', help='Force sequential upload of files in order (by default, files are uploaded in parallel although the progress bars are displayed in ascending file size order)')
+
 parser.add_argument('--delete', nargs=1, dest='share_or_file', help='Delete a share or a file (url or path)')
 
 auth_group = parser.add_argument_group('Authentification (optional)')
         print('%s: %s' % (name, file.url))
 
         upload = FileUpload(file, fp)
-        upload.start()
+
+        if not args.seq:
+            upload.start()
+
         uploads.append(upload)
 
     print()
 
-    uploads.sort(key=lambda item: item.file_size)
+    if not args.seq:
+        uploads.sort(key=lambda item: item.file_size)
 
     def print_status(upload, index, count):
         name = upload.file.name
         sys.stderr.write('\r%s (%d/%d) %s %d %%' % (name, index, count, bar, upload.percent_done))
 
     for i, upload in enumerate(uploads):
+        if args.seq:
+            upload.start()
+
         while True:
             print_status(upload, i + 1, len(uploads))
             upload.join(0.5)