cc-4105: workaround for fix for terrible bug
This commit is contained in:
parent
9015b93527
commit
0e2d523bf6
|
@ -24,7 +24,6 @@ class ReportHandler(Handles):
|
||||||
weak=weak)
|
weak=weak)
|
||||||
|
|
||||||
def report_problem_file(self, event, exception=None):
|
def report_problem_file(self, event, exception=None):
|
||||||
import ipdb; ipdb.set_trace()
|
|
||||||
dispatcher.send(signal=self.report_signal, sender=self, event=event,
|
dispatcher.send(signal=self.report_signal, sender=self, event=event,
|
||||||
exception=exception)
|
exception=exception)
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ def mediate_ignored(fn):
|
||||||
for s_check in skip_events:
|
for s_check in skip_events:
|
||||||
FileMediator.skip_checks.remove( s_check )
|
FileMediator.skip_checks.remove( s_check )
|
||||||
# Only process skip_checks one at a time
|
# Only process skip_checks one at a time
|
||||||
|
FileMediator.logger.info("Skip checked: '%s'" % str(event))
|
||||||
return
|
return
|
||||||
if FileMediator.is_ignored(event.pathname):
|
if FileMediator.is_ignored(event.pathname):
|
||||||
FileMediator.logger.info("Ignoring: '%s' (once)" % event.pathname)
|
FileMediator.logger.info("Ignoring: '%s' (once)" % event.pathname)
|
||||||
|
@ -108,7 +109,6 @@ class OrganizeListener(BaseListener, pyinotify.ProcessEvent, Loggable):
|
||||||
@mediate_ignored
|
@mediate_ignored
|
||||||
@IncludeOnly(mmp.supported_extensions)
|
@IncludeOnly(mmp.supported_extensions)
|
||||||
def process_to_organize(self, event):
|
def process_to_organize(self, event):
|
||||||
import ipdb; ipdb.set_trace()
|
|
||||||
dispatcher.send(signal=self.signal, sender=self,
|
dispatcher.send(signal=self.signal, sender=self,
|
||||||
event=OrganizeFile(event))
|
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
|
# into file events until we know for sure if we deleted or moved
|
||||||
morph = MoveDir(event) if event.dir else MoveFile(event)
|
morph = MoveDir(event) if event.dir else MoveFile(event)
|
||||||
EventRegistry.matching(event).morph_into(morph)
|
EventRegistry.matching(event).morph_into(morph)
|
||||||
#else: self.process_create(event)
|
else: self.process_create(event)
|
||||||
def process_IN_MOVED_FROM(self, event):
|
def process_IN_MOVED_FROM(self, event):
|
||||||
# Is either delete dir or delete file
|
# Is either delete dir or delete file
|
||||||
evt = self.process_delete(event)
|
evt = self.process_delete(event)
|
||||||
|
|
|
@ -75,12 +75,22 @@ class Manager(Loggable):
|
||||||
|
|
||||||
def __create_organizer(self, target_path, recorded_path):
|
def __create_organizer(self, target_path, recorded_path):
|
||||||
"""
|
"""
|
||||||
private constructor for organizer so that we don't have to repeat
|
creates an organizer at new destination path or modifies the old one
|
||||||
adding the channel/signal as a parameter to the original constructor
|
|
||||||
every time
|
|
||||||
"""
|
"""
|
||||||
return Organizer(channel=self.organize_channel,target_path=target_path,
|
# We avoid creating new instances of organize because of the way it
|
||||||
recorded_path=recorded_path)
|
# 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):
|
def get_problem_files_path(self):
|
||||||
return self.organize['problem_files_path']
|
return self.organize['problem_files_path']
|
||||||
|
@ -96,8 +106,7 @@ class Manager(Loggable):
|
||||||
def set_recorded_path(self, new_path):
|
def set_recorded_path(self, new_path):
|
||||||
self.__remove_watch(self.organize['recorded_path'])
|
self.__remove_watch(self.organize['recorded_path'])
|
||||||
self.organize['recorded_path'] = new_path
|
self.organize['recorded_path'] = new_path
|
||||||
self.organize['organizer'] = self.__create_organizer(
|
self.__create_organizer( self.organize['imported_path'], new_path)
|
||||||
self.organize['imported_path'], new_path)
|
|
||||||
self.__add_watch(new_path, self.watch_listener)
|
self.__add_watch(new_path, self.watch_listener)
|
||||||
|
|
||||||
def get_organize_path(self):
|
def get_organize_path(self):
|
||||||
|
@ -130,8 +139,7 @@ class Manager(Loggable):
|
||||||
"""
|
"""
|
||||||
self.__remove_watch(self.organize['imported_path'])
|
self.__remove_watch(self.organize['imported_path'])
|
||||||
self.organize['imported_path'] = new_path
|
self.organize['imported_path'] = new_path
|
||||||
self.organize['organizer'] = self.__create_organizer(
|
self.__create_organizer( new_path, self.organize['recorded_path'])
|
||||||
new_path, self.organize['recorded_path'])
|
|
||||||
self.__add_watch(new_path, self.watch_listener)
|
self.__add_watch(new_path, self.watch_listener)
|
||||||
|
|
||||||
def change_storage_root(self, store):
|
def change_storage_root(self, store):
|
||||||
|
|
|
@ -14,11 +14,22 @@ class Organizer(ReportHandler,Loggable):
|
||||||
pyinotify. (These events are fed to it through StoreWatchListener)
|
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):
|
def __init__(self, channel, target_path, recorded_path):
|
||||||
self.channel = channel
|
self.channel = channel
|
||||||
self.target_path = target_path
|
self.target_path = target_path
|
||||||
self.recorded_path = recorded_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):
|
def handle(self, sender, event):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue