cc-4105: workaround for fix for terrible bug

This commit is contained in:
Rudi Grinberg 2012-08-10 13:16:10 -04:00
parent 9015b93527
commit 0e2d523bf6
4 changed files with 31 additions and 13 deletions

View File

@ -24,7 +24,6 @@ class ReportHandler(Handles):
weak=weak)
def report_problem_file(self, event, exception=None):
import ipdb; ipdb.set_trace()
dispatcher.send(signal=self.report_signal, sender=self, event=event,
exception=exception)

View File

@ -71,6 +71,7 @@ def mediate_ignored(fn):
for s_check in skip_events:
FileMediator.skip_checks.remove( s_check )
# Only process skip_checks one at a time
FileMediator.logger.info("Skip checked: '%s'" % str(event))
return
if FileMediator.is_ignored(event.pathname):
FileMediator.logger.info("Ignoring: '%s' (once)" % event.pathname)
@ -108,7 +109,6 @@ class OrganizeListener(BaseListener, pyinotify.ProcessEvent, Loggable):
@mediate_ignored
@IncludeOnly(mmp.supported_extensions)
def process_to_organize(self, event):
import ipdb; ipdb.set_trace()
dispatcher.send(signal=self.signal, sender=self,
event=OrganizeFile(event))
@ -121,7 +121,7 @@ class StoreWatchListener(BaseListener, Loggable, pyinotify.ProcessEvent):
# into file events until we know for sure if we deleted or moved
morph = MoveDir(event) if event.dir else MoveFile(event)
EventRegistry.matching(event).morph_into(morph)
#else: self.process_create(event)
else: self.process_create(event)
def process_IN_MOVED_FROM(self, event):
# Is either delete dir or delete file
evt = self.process_delete(event)

View File

@ -75,12 +75,22 @@ class Manager(Loggable):
def __create_organizer(self, target_path, recorded_path):
"""
private constructor for organizer so that we don't have to repeat
adding the channel/signal as a parameter to the original constructor
every time
creates an organizer at new destination path or modifies the old one
"""
return Organizer(channel=self.organize_channel,target_path=target_path,
recorded_path=recorded_path)
# We avoid creating new instances of organize because of the way it
# interacts with pydispatch. We must be careful to never have more than
# one instance of OrganizeListener but this is not so easy. (The
# singleton hack in Organizer) doesn't work. This is the only thing
# that seems to work.
if self.organize['organizer']:
o = self.organize['organizer']
o.channel = self.organize_channel
o.target_path = target_path
o.recorded_path = recorded_path
else:
self.organize['organizer'] = Organizer(channel=
self.organize_channel, target_path=target_path,
recorded_path=recorded_path)
def get_problem_files_path(self):
return self.organize['problem_files_path']
@ -96,8 +106,7 @@ class Manager(Loggable):
def set_recorded_path(self, new_path):
self.__remove_watch(self.organize['recorded_path'])
self.organize['recorded_path'] = new_path
self.organize['organizer'] = self.__create_organizer(
self.organize['imported_path'], new_path)
self.__create_organizer( self.organize['imported_path'], new_path)
self.__add_watch(new_path, self.watch_listener)
def get_organize_path(self):
@ -130,8 +139,7 @@ class Manager(Loggable):
"""
self.__remove_watch(self.organize['imported_path'])
self.organize['imported_path'] = new_path
self.organize['organizer'] = self.__create_organizer(
new_path, self.organize['recorded_path'])
self.__create_organizer( new_path, self.organize['recorded_path'])
self.__add_watch(new_path, self.watch_listener)
def change_storage_root(self, store):

View File

@ -14,11 +14,22 @@ class Organizer(ReportHandler,Loggable):
pyinotify. (These events are fed to it through StoreWatchListener)
"""
_instance = None
def __new__(cls, channel, target_path, recorded_path):
if cls._instance:
cls._instance.channel = channel
cls._instance.target_path = target_path
cls._instance.recorded_path = recorded_path
else:
cls._instance = super(Organizer, cls).__new__( cls, channel,
target_path, recorded_path)
return cls._instance
def __init__(self, channel, target_path, recorded_path):
self.channel = channel
self.target_path = target_path
self.recorded_path = recorded_path
super(Organizer, self).__init__(signal=self.channel, weak=True)
super(Organizer, self).__init__(signal=self.channel, weak=False)
def handle(self, sender, event):
"""