mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 17:06:17 +00:00
Prevent issuing useless move operations if files have been created
This commit is contained in:
parent
1282a5ab12
commit
e73b358c63
@ -29,9 +29,10 @@ from watchdog.events import PatternMatchingEventHandler
|
|||||||
from supysonic import config, db
|
from supysonic import config, db
|
||||||
from supysonic.scanner import Scanner
|
from supysonic.scanner import Scanner
|
||||||
|
|
||||||
OP_SCAN = 1
|
OP_SCAN = 1
|
||||||
OP_REMOVE = 2
|
OP_REMOVE = 2
|
||||||
OP_MOVE = 4
|
OP_MOVE = 4
|
||||||
|
FLAG_CREATE = 8
|
||||||
|
|
||||||
class SupysonicWatcherEventHandler(PatternMatchingEventHandler):
|
class SupysonicWatcherEventHandler(PatternMatchingEventHandler):
|
||||||
def __init__(self, queue, logger):
|
def __init__(self, queue, logger):
|
||||||
@ -50,7 +51,7 @@ class SupysonicWatcherEventHandler(PatternMatchingEventHandler):
|
|||||||
|
|
||||||
def on_created(self, event):
|
def on_created(self, event):
|
||||||
self.__logger.debug("File created: '%s'", event.src_path)
|
self.__logger.debug("File created: '%s'", event.src_path)
|
||||||
self.__queue.put(event.src_path, OP_SCAN)
|
self.__queue.put(event.src_path, OP_SCAN | FLAG_CREATE)
|
||||||
|
|
||||||
def on_deleted(self, event):
|
def on_deleted(self, event):
|
||||||
self.__logger.debug("File deleted: '%s'", event.src_path)
|
self.__logger.debug("File deleted: '%s'", event.src_path)
|
||||||
@ -83,6 +84,8 @@ class Event(object):
|
|||||||
self.__op &= ~OP_REMOVE
|
self.__op &= ~OP_REMOVE
|
||||||
if operation & OP_REMOVE:
|
if operation & OP_REMOVE:
|
||||||
self.__op &= ~OP_SCAN
|
self.__op &= ~OP_SCAN
|
||||||
|
if operation & FLAG_CREATE:
|
||||||
|
self.__op &= ~OP_MOVE
|
||||||
self.__op |= operation
|
self.__op |= operation
|
||||||
|
|
||||||
src_path = kwargs.get("src_path")
|
src_path = kwargs.get("src_path")
|
||||||
|
Loading…
Reference in New Issue
Block a user