MCPcopy Index your code
hub / github.com/pyload/pyload / FileHandler

Class FileHandler

module/database/FileDatabase.py:36–574  ·  view source on GitHub ↗

Handles all request made to obtain information, modify status or other request for links or packages

Source from the content-addressed store, hash-verified

34
35
36class FileHandler:
37 """Handles all request made to obtain information,
38 modify status or other request for links or packages"""
39
40 def __init__(self, core):
41 """Constructor"""
42 self.core = core
43
44 # translations
45 self.statusMsg = [_("finished"), _("offline"), _("online"), _("queued"), _("skipped"), _("waiting"), _("temp. offline"), _("starting"), _("failed"), _("aborted"), _("decrypting"), _("custom"), _("downloading"), _("processing"), _("unknown")]
46
47 self.cache = {} #holds instances for files
48 self.packageCache = {} # same for packages
49 #@TODO: purge the cache
50
51 self.jobCache = {}
52
53 self.lock = RLock() #@TODO should be a Lock w/o R
54 #self.lock._Verbose__verbose = True
55
56 self.filecount = -1 # if an invalid value is set get current value from db
57 self.queuecount = -1 #number of package to be loaded
58 self.unchanged = False #determines if any changes was made since last call
59
60 self.db = self.core.db
61
62 def change(func):
63 def new(*args):
64 args[0].unchanged = False
65 args[0].filecount = -1
66 args[0].queuecount = -1
67 args[0].jobCache = {}
68 return func(*args)
69 return new
70
71 #----------------------------------------------------------------------
72 def save(self):
73 """saves all data to backend"""
74 self.db.commit()
75
76 #----------------------------------------------------------------------
77 def syncSave(self):
78 """saves all data to backend and waits until all data are written"""
79 pyfiles = self.cache.values()
80 for pyfile in pyfiles:
81 pyfile.sync()
82
83 pypacks = self.packageCache.values()
84 for pypack in pypacks:
85 pypack.sync()
86
87 self.db.syncSave()
88
89 @lock
90 def getCompleteData(self, queue=1):
91 """gets a complete data representation"""
92
93 data = self.db.getAllLinks(queue)

Callers 2

setupDBMethod · 0.90
FileDatabase.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected