Browse Source

Working "full/quick" scan

pull/460/merge
Ruud 13 years ago
parent
commit
f410ba13f4
  1. 15
      couchpotato/core/plugins/manage/main.py
  2. 19
      couchpotato/core/plugins/scanner/main.py
  3. 2
      couchpotato/static/scripts/page/manage.js

15
couchpotato/core/plugins/manage/main.py

@ -1,6 +1,6 @@
from couchpotato.api import addApiView from couchpotato.api import addApiView
from couchpotato.core.event import fireEvent, addEvent, fireEventAsync from couchpotato.core.event import fireEvent, addEvent, fireEventAsync
from couchpotato.core.helpers.request import jsonified, getParams from couchpotato.core.helpers.request import jsonified, getParam
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin from couchpotato.core.plugins.base import Plugin
from couchpotato.environment import Env from couchpotato.environment import Env
@ -25,13 +25,14 @@ class Manage(Plugin):
}) })
if not Env.get('dev'): if not Env.get('dev'):
addEvent('app.load', self.updateLibrary) def updateLibrary():
self.updateLibrary(full = False)
addEvent('app.load', updateLibrary)
def updateLibraryView(self): def updateLibraryView(self):
params = getParams() full = getParam('full', default = 1)
fireEventAsync('manage.update', full = True if full == '1' else False)
fireEventAsync('manage.update', full = params.get('full', True))
return jsonified({ return jsonified({
'success': True 'success': True
@ -55,7 +56,7 @@ class Manage(Plugin):
continue continue
log.info('Updating manage library: %s' % directory) log.info('Updating manage library: %s' % directory)
identifiers = fireEvent('scanner.folder', folder = directory, newer_than = last_update, single = True) identifiers = fireEvent('scanner.folder', folder = directory, newer_than = last_update if not full else 0, single = True)
if identifiers: if identifiers:
added_identifiers.extend(identifiers) added_identifiers.extend(identifiers)
@ -71,7 +72,7 @@ class Manage(Plugin):
for done_movie in done_movies: for done_movie in done_movies:
if done_movie['library']['identifier'] not in added_identifiers: if done_movie['library']['identifier'] not in added_identifiers:
fireEvent('movie.delete', movie_id = done_movie['id']) fireEvent('movie.delete', movie_id = done_movie['id'], delete_from = 'all')
Env.prop('manage.last_update', time.time()) Env.prop('manage.last_update', time.time())

19
couchpotato/core/plugins/scanner/main.py

@ -103,14 +103,14 @@ class Scanner(Plugin):
if group['library']: if group['library']:
fireEvent('release.add', group = group) fireEvent('release.add', group = group)
def scanFolderToLibrary(self, folder = None, newer_than = None, simple = True): def scanFolderToLibrary(self, folder = None, newer_than = 0, simple = True):
folder = os.path.normpath(folder) folder = os.path.normpath(folder)
if not os.path.isdir(folder): if not os.path.isdir(folder):
return return
groups = self.scan(folder = folder, simple = simple) groups = self.scan(folder = folder, simple = simple, newer_than = newer_than)
added_identifier = [] added_identifier = []
while True and not self.shuttingDown(): while True and not self.shuttingDown():
@ -131,7 +131,7 @@ class Scanner(Plugin):
return added_identifier return added_identifier
def scan(self, folder = None, files = [], simple = False): def scan(self, folder = None, files = [], simple = False, newer_than = 0):
folder = os.path.normpath(folder) folder = os.path.normpath(folder)
@ -312,6 +312,19 @@ class Scanner(Plugin):
del group['unsorted_files'] del group['unsorted_files']
continue continue
# Only process movies newer than x
if newer_than and newer_than > 0:
for cur_file in group['unsorted_files']:
file_time = [os.path.getmtime(cur_file), os.path.getctime(cur_file)]
if file_time[0] > time.time() or file_time[1] > time.time():
break
log.debug('None of the files have changed since %s for %s, skipping.' % (time.ctime(newer_than), identifier))
# Delete the unsorted list
del group['unsorted_files']
continue continue
# Group extra (and easy) files first # Group extra (and easy) files first

2
couchpotato/static/scripts/page/manage.js

@ -41,7 +41,7 @@ Page.Manage = new Class({
Api.request('manage.update', { Api.request('manage.update', {
'data': { 'data': {
'full': full ? 1 : null 'full': +full
} }
}) })

Loading…
Cancel
Save