Repository: Duke-GCB/DukeDSClient

Issue:
“range() step argument must not be zero”
Crash at approx. 30% completion, uploading a folder to a new project: “range() step argument must not be zero”
<img width="806" alt="screen shot 2016-05-25 at 1 31 11 pm" src="https://cloud.githubusercontent.com/assets/11540881/15551266/38d08f16-2283-11e6-9708-c5f93edb99d9.png">

Is there a verbose logging option we can use to determine where, exactly, this is failing?

Discussion:

Patch:
diff --git a/ddsc/core/filedownloader.py b/ddsc/core/filedownloader.py
index 5049aac..e8ab7f5 100644
--- a/ddsc/core/filedownloader.py
+++ b/ddsc/core/filedownloader.py
@@ -106,8 +106,9 @@ class FileDownloader(object):
         Write out a empty file so the workers can seek to where they should write and write their data.
         """
         with open(self.path, "wb") as outfile:
-            outfile.seek(int(self.file_size) - 1)
-            outfile.write(b'\0')
+            if self.file_size > 0:
+                outfile.seek(int(self.file_size) - 1)
+                outfile.write(b'\0')
 
     def make_and_start_process(self, range_start, range_end, progress_queue):
         """
diff --git a/ddsc/core/fileuploader.py b/ddsc/core/fileuploader.py
index 43356c5..4b57b61 100644
--- a/ddsc/core/fileuploader.py
+++ b/ddsc/core/fileuploader.py
@@ -181,12 +181,14 @@ class ParallelChunkProcessor(object):
             processes.append(self.make_and_start_process(index, num_items, progress_queue))
         wait_for_processes(processes, num_chunks, progress_queue, self.watcher, self.local_file)
 
-
     @staticmethod
     def determine_num_chunks(chunk_size, file_size):
         """
         Figure out how many pieces we are sending the file in.
+        NOTE: duke-data-service requires an empty chunk to be uploaded for empty files.
         """
+        if file_size == 0:
+            return 1
         return int(math.ceil(float(file_size) / float(chunk_size)))
 
     @staticmethod
diff --git a/ddsc/tests/empty_file b/ddsc/tests/empty_file
new file mode 100644
index 0000000..e69de29
diff --git a/setup.py b/setup.py
index 8fee84a..2fe9f5b 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@ from setuptools import setup
 
 
 setup(name='DukeDSClient',
-        version='0.2.8',
+        version='0.2.9',
         description='Command line tool(ddsclient) to upload/manage projects on the duke-data-service.',
         url='https://github.com/Duke-GCB/DukeDSClient',
         keywords='duke dds dukedataservice',


Test patch:
diff --git a/ddsc/core/tests/test_fileuploader.py b/ddsc/core/tests/test_fileuploader.py
index f8ca72b..44bfb7e 100644
--- a/ddsc/core/tests/test_fileuploader.py
+++ b/ddsc/core/tests/test_fileuploader.py
@@ -47,6 +47,7 @@ class TestParallelChunkProcessor(TestCase):
             (100, 900000, 9000),
             (125, 123, 1),
             (122, 123, 2),
+            (100, 0, 1)
         ]
         for chunk_size, file_size, expected in values:
             num_chunks = ParallelChunkProcessor.determine_num_chunks(chunk_size, file_size)
@@ -63,4 +64,4 @@ class TestParallelChunkProcessor(TestCase):
         ]
         for upload_workers, num_chunks, expected in values:
             result = ParallelChunkProcessor.make_work_parcels(upload_workers, num_chunks)
-            self.assertEqual(expected, result)
\ No newline at end of file
+            self.assertEqual(expected, result)