From af7c7da7358cd05e9b421eee22b9f307d69e5581 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Thu, 29 Mar 2018 02:59:11 +0200 Subject: [PATCH] Optional file downloaded checking by separate function --- src/Content/ContentManager.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Content/ContentManager.py b/src/Content/ContentManager.py index d923471b..ff6d3594 100644 --- a/src/Content/ContentManager.py +++ b/src/Content/ContentManager.py @@ -304,6 +304,14 @@ class ContentManager(object): else: return False + def isDownloaded(self, inner_path, hash_id=None): + if not hash_id: + file_info = self.getFileInfo(inner_path) + if not file_info or "sha512" not in file_info: + return False + hash_id = self.hashfield.getHashId(file_info["sha512"]) + return hash_id in self.hashfield + # Find the file info line from self.contents # Return: { "sha512": "c29d73d...21f518", "size": 41 , "content_inner_path": "content.json"} def getFileInfo(self, inner_path, new_file=False):