MCPcopy
hub / github.com/pyload/pyload / checkForSameFiles

Method checkForSameFiles

module/plugins/Plugin.py:575–605  ·  view source on GitHub ↗

checks if same file was/is downloaded within same package :param starting: indicates that the current download is going to start :raises SkipDownload:

(self, starting=False)

Source from the content-addressed store, hash-verified

573
574
575 def checkForSameFiles(self, starting=False):
576 """ checks if same file was/is downloaded within same package
577
578 :param starting: indicates that the current download is going to start
579 :raises SkipDownload:
580 """
581
582 pack = self.pyfile.package()
583
584 for pyfile in self.core.files.cache.values():
585 if pyfile != self.pyfile and pyfile.name == self.pyfile.name and pyfile.package().folder == pack.folder:
586 if pyfile.status in (0, 12): #finished or downloading
587 raise SkipDownload(pyfile.pluginname)
588 elif pyfile.status in (
589 5, 7) and starting: #a download is waiting/starting and was appenrently started before
590 raise SkipDownload(pyfile.pluginname)
591
592 download_folder = self.config['general']['download_folder']
593 location = save_join(download_folder, pack.folder, self.pyfile.name)
594
595 if starting and self.core.config['download']['skip_existing'] and exists(location):
596 size = os.stat(location).st_size
597 if size >= self.pyfile.size:
598 raise SkipDownload("File exists.")
599
600 pyfile = self.core.db.findDuplicates(self.pyfile.id, self.pyfile.package().folder, self.pyfile.name)
601 if pyfile:
602 if exists(location):
603 raise SkipDownload(pyfile[0])
604
605 self.log.debug("File %s not skipped, because it does not exists." % self.pyfile.name)
606
607 def clean(self):
608 """ clean everything and remove references """

Callers 2

downloadMethod · 0.95
runMethod · 0.45

Calls 6

save_joinFunction · 0.90
SkipDownloadClass · 0.85
existsFunction · 0.85
packageMethod · 0.80
valuesMethod · 0.80
findDuplicatesMethod · 0.80

Tested by

no test coverage detected