Skip to content

Commit e430b3d

Browse files
author
Veselin Penev
committed
bug fix in api.chunk_write()
1 parent 688e0c7 commit e430b3d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

bitdust/interface/api.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
#------------------------------------------------------------------------------
3737

38-
_Debug = False
38+
_Debug = True
3939
_DebugLevel = 10
4040

4141
_APILogFileEnabled = None
@@ -404,13 +404,13 @@ def chunk_write(data, path=None):
404404
if not path.startswith(tmpfile.base_dir()):
405405
return ERROR('wrong path location provided')
406406
else:
407-
file_path = tmpfile.make('upload', close_fd=True)
407+
_, file_path = tmpfile.make('upload', close_fd=True)
408408
try:
409-
chunk.data_write(data=data, file_path=file_path)
409+
chunk.data_write(file_path=file_path, data=data, from_text=True)
410410
except Exception as exc:
411411
return ERROR(exc)
412412
if not path:
413-
OK({'path': file_path})
413+
return OK({'path': file_path})
414414
return OK()
415415

416416

bitdust/stream/chunk.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def data_read(file_path, offset, max_size, to_text=True):
5959
def data_write(file_path, data, from_text=True):
6060
if from_text:
6161
data = strng.to_bin(data, encoding='latin1')
62-
f = open(file_path, 'wb')
62+
f = open(file_path, 'ab')
6363
f.write(data)
6464
f.close()
6565
if _Debug:

0 commit comments

Comments
 (0)