Skip to content

Commit b88749a

Browse files
authored
Merge pull request #209 from Azure/Uploader-SingleFile-Issue
fixed upload issue for directory with single file
2 parents 923cc64 + 1541144 commit b88749a

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
Release History
44
===============
55

6+
0.0.19 (2018-03-14)
7+
-------------------
8+
* Fixed upload issue where destination filename was wrong while upload of directory with single file #208
9+
610
0.0.18 (2018-02-05)
711
-------------------
812
* Fixed read issue where whole file was cached while doing positional reads #198

azure/datalake/store/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# license information.
77
# --------------------------------------------------------------------------
88

9-
__version__ = "0.0.18"
9+
__version__ = "0.0.19"
1010

1111
from .core import AzureDLFileSystem
1212
from .multithread import ADLDownloader

azure/datalake/store/multithread.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,17 +441,19 @@ def hash(self):
441441
def _setup(self):
442442
""" Create set of parameters to loop over
443443
"""
444+
is_path_walk_empty = False
444445
if "*" not in self.lpath:
445446
out = os.walk(self.lpath)
446447
lfiles = sum(([os.path.join(dir, f) for f in fnames] for
447448
(dir, _, fnames) in out), [])
448449
if (not lfiles and os.path.exists(self.lpath) and
449450
not os.path.isdir(self.lpath)):
450451
lfiles = [self.lpath]
452+
is_path_walk_empty = True
451453
else:
452454
lfiles = glob.glob(self.lpath)
453455

454-
if len(lfiles) > 1:
456+
if len(lfiles) > 0 and not is_path_walk_empty:
455457
local_rel_lpath = str(AzureDLPath(self.lpath).globless_prefix)
456458
file_pairs = [(f, self.rpath / AzureDLPath(f).relative_to(local_rel_lpath)) for f in lfiles]
457459
elif lfiles:

tests/test_multithread.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ def local_files(tempdir):
226226
f.write(b'0123456789')
227227
yield filenames
228228

229-
230229
@my_vcr.use_cassette
231230
def test_upload_one(local_files, azure):
232231
with azure_teardown(azure):
@@ -253,6 +252,23 @@ def test_upload_one(local_files, azure):
253252

254253
azure.rm(test_dir / 'bigfile')
255254

255+
@my_vcr.use_cassette
256+
def test_upload_single_file_in_dir(tempdir, azure):
257+
with azure_teardown(azure):
258+
lpath_dir = tempdir
259+
lfilename = os.path.join(lpath_dir, 'singlefile')
260+
with open(lfilename, 'wb') as f:
261+
f.write(b'0123456789')
262+
263+
# transfer client w/ deterministic temporary directory
264+
from azure.datalake.store.multithread import put_chunk
265+
client = ADLTransferClient(azure, transfer=put_chunk,
266+
unique_temporary=False)
267+
268+
up = ADLUploader(azure, test_dir / 'singlefiledir', lpath_dir, nthreads=1,
269+
overwrite=True)
270+
assert azure.info(test_dir / 'singlefiledir' / 'singlefile')['length'] == 10
271+
azure.rm(test_dir / 'singlefiledir' / 'singlefile')
256272

257273
@my_vcr.use_cassette
258274
def test_upload_one_empty_file(local_files, azure):

0 commit comments

Comments
 (0)