diff --git a/plugins/Bigfile/BigfilePlugin.py b/plugins/Bigfile/BigfilePlugin.py index 87c94cf8..60bdb4a8 100644 --- a/plugins/Bigfile/BigfilePlugin.py +++ b/plugins/Bigfile/BigfilePlugin.py @@ -126,7 +126,7 @@ class UiWebsocketPlugin(object): nonce = CryptHash.random() piece_size = 1024 * 1024 inner_path = self.site.content_manager.sanitizePath(inner_path) - file_info = self.site.content_manager.getFileInfo(inner_path) + file_info = self.site.content_manager.getFileInfo(inner_path, new_file=True) content_inner_path_dir = helper.getDirname(file_info["content_inner_path"]) file_relative_path = inner_path[len(content_inner_path_dir):] @@ -150,13 +150,13 @@ class UiWebsocketPlugin(object): @PluginManager.registerTo("ContentManager") class ContentManagerPlugin(object): - def getFileInfo(self, inner_path): + def getFileInfo(self, inner_path, *args, **kwargs): if "|" not in inner_path: - return super(ContentManagerPlugin, self).getFileInfo(inner_path) + return super(ContentManagerPlugin, self).getFileInfo(inner_path, *args, **kwargs) inner_path, file_range = inner_path.split("|") pos_from, pos_to = map(int, file_range.split("-")) - file_info = super(ContentManagerPlugin, self).getFileInfo(inner_path) + file_info = super(ContentManagerPlugin, self).getFileInfo(inner_path, *args, **kwargs) return file_info def readFile(self, file_in, size, buff_size=1024 * 64): diff --git a/src/Content/ContentManager.py b/src/Content/ContentManager.py index 61ae97b5..0813e2af 100644 --- a/src/Content/ContentManager.py +++ b/src/Content/ContentManager.py @@ -302,7 +302,7 @@ class ContentManager(object): # Find the file info line from self.contents # Return: { "sha512": "c29d73d...21f518", "size": 41 , "content_inner_path": "content.json"} - def getFileInfo(self, inner_path): + def getFileInfo(self, inner_path, new_file=False): dirs = inner_path.split("/") # Parent dirs of content.json inner_path_parts = [dirs.pop()] # Filename relative to content.json while True: @@ -338,6 +338,14 @@ class ContentManager(object): else: back["content_inner_path"] = content_inner_path_dir + "content.json" back["optional"] = None + back["relative_path"] = "/".join(inner_path_parts) + return back + + if new_file and content: + back = {} + back["content_inner_path"] = content_inner_path + back["relative_path"] = "/".join(inner_path_parts) + back["optional"] = None return back # No inner path in this dir, lets try the parent dir @@ -874,7 +882,7 @@ class ContentManager(object): else: # Check using sha512 hash file_info = self.getFileInfo(inner_path) if file_info: - if CryptHash.sha512sum(file) != file_info["sha512"]: + if CryptHash.sha512sum(file) != file_info.get("sha512", ""): raise VerifyError("Invalid hash") if file_info.get("size", 0) != file.tell():