From 9b4b9334a3bacd275daed4a602fc516bf54bbc56 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Mon, 15 Oct 2018 13:12:46 +0200 Subject: [PATCH] Remove pinned status of a file on file deletion --- plugins/OptionalManager/OptionalManagerPlugin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/OptionalManager/OptionalManagerPlugin.py b/plugins/OptionalManager/OptionalManagerPlugin.py index 9a512793..72874b7f 100644 --- a/plugins/OptionalManager/OptionalManagerPlugin.py +++ b/plugins/OptionalManager/OptionalManagerPlugin.py @@ -1,6 +1,9 @@ import time +import re import collections +import gevent + from util import helper from Plugin import PluginManager import ContentDbPlugin @@ -72,16 +75,16 @@ class ContentManagerPlugin(object): def optionalRemoved(self, inner_path, hash_id, size=None): self.contents.db.execute( - "UPDATE file_optional SET is_downloaded = 0, peer = peer - 1 WHERE site_id = :site_id AND inner_path = :inner_path AND is_downloaded = 1", + "UPDATE file_optional SET is_downloaded = 0, is_pinned = 0, peer = peer - 1 WHERE site_id = :site_id AND inner_path = :inner_path AND is_downloaded = 1", {"site_id": self.contents.db.site_ids[self.site.address], "inner_path": inner_path} ) - print "Removed hash_id: %s" % hash_id, self.contents.db.cur.cursor.rowcount if self.contents.db.cur.cursor.rowcount > 0: back = super(ContentManagerPlugin, self).optionalRemoved(inner_path, hash_id, size) # Re-add to hashfield if we have other file with the same hash_id if self.isDownloaded(hash_id=hash_id, force_check_db=True): self.hashfield.appendHashId(hash_id) + return back def isDownloaded(self, inner_path=None, hash_id=None, force_check_db=False): if hash_id and not force_check_db and hash_id not in self.hashfield: