Rev3323, Fix bigfile download to non-existent directory

This commit is contained in:
shortcutme 2018-02-11 01:48:17 +01:00
parent 56f057143e
commit 39366bfbf1
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 8 additions and 2 deletions

View file

@ -267,7 +267,8 @@ class ContentManagerPlugin(object):
piecemap_inner_path = inner_path + ".piecemap.msgpack" piecemap_inner_path = inner_path + ".piecemap.msgpack"
msgpack.pack({file_name: piecemap_info}, self.site.storage.open(piecemap_inner_path, "wb")) msgpack.pack({file_name: piecemap_info}, self.site.storage.open(piecemap_inner_path, "wb"))
back.update(super(ContentManagerPlugin, self).hashFile(dir_inner_path, piecemap_relative_path, True))
back.update(super(ContentManagerPlugin, self).hashFile(dir_inner_path, piecemap_relative_path, optional=True))
piece_num = int(math.ceil(float(file_size) / piece_size)) piece_num = int(math.ceil(float(file_size) / piece_size))
@ -345,6 +346,11 @@ class SiteStoragePlugin(object):
def createSparseFile(self, inner_path, size, sha512=None): def createSparseFile(self, inner_path, size, sha512=None):
file_path = self.getPath(inner_path) file_path = self.getPath(inner_path)
file_dir = os.path.dirname(file_path)
if not os.path.isdir(file_dir):
os.makedirs(file_dir)
f = open(file_path, 'wb') f = open(file_path, 'wb')
f.truncate(size) f.truncate(size)
f.close() f.close()

View file

@ -10,7 +10,7 @@ class Config(object):
def __init__(self, argv): def __init__(self, argv):
self.version = "0.6.2" self.version = "0.6.2"
self.rev = 3321 self.rev = 3323
self.argv = argv self.argv = argv
self.action = None self.action = None
self.config_file = "zeronet.conf" self.config_file = "zeronet.conf"