Remove pinned status of a file on file deletion
This commit is contained in:
parent
96d40d9816
commit
9b4b9334a3
1 changed files with 5 additions and 2 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue