file_manager: add watches for hidden directories
The logic used to sync requests to modify contents in hidden directories is no longer necessary, thus removed. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
3d0d1e1dcb
commit
aeb24dabdb
|
@ -192,13 +192,6 @@ class FileManager:
|
||||||
return ""
|
return ""
|
||||||
return os.path.relpath(full_path, start=root_dir)
|
return os.path.relpath(full_path, start=root_dir)
|
||||||
|
|
||||||
def has_hidden_dir(self, rel_path: str) -> bool:
|
|
||||||
parts = rel_path.split("/")
|
|
||||||
for part in parts:
|
|
||||||
if part and part[0] == '.':
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def check_file_exists(self, root: str, filename: str) -> bool:
|
def check_file_exists(self, root: str, filename: str) -> bool:
|
||||||
root_dir = self.file_paths.get(root, "")
|
root_dir = self.file_paths.get(root, "")
|
||||||
file_path = os.path.join(root_dir, filename)
|
file_path = os.path.join(root_dir, filename)
|
||||||
|
@ -274,8 +267,7 @@ class FileManager:
|
||||||
self.notify_sync_lock.cancel()
|
self.notify_sync_lock.cancel()
|
||||||
self.notify_sync_lock = None
|
self.notify_sync_lock = None
|
||||||
raise
|
raise
|
||||||
if not self.has_hidden_dir(directory):
|
await self.notify_sync_lock.wait(30.)
|
||||||
await self.notify_sync_lock.wait(30.)
|
|
||||||
self.notify_sync_lock = None
|
self.notify_sync_lock = None
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
@ -375,9 +367,7 @@ class FileManager:
|
||||||
self.notify_sync_lock = None
|
self.notify_sync_lock = None
|
||||||
raise self.server.error(str(e))
|
raise self.server.error(str(e))
|
||||||
self.notify_sync_lock.update_dest(full_dest)
|
self.notify_sync_lock.update_dest(full_dest)
|
||||||
if not self.has_hidden_dir(self.get_relative_path(
|
await self.notify_sync_lock.wait(600.)
|
||||||
dest_root, full_dest)):
|
|
||||||
await self.notify_sync_lock.wait(600.)
|
|
||||||
self.notify_sync_lock = None
|
self.notify_sync_lock = None
|
||||||
result['item']['path'] = self.get_relative_path(dest_root, full_dest)
|
result['item']['path'] = self.get_relative_path(dest_root, full_dest)
|
||||||
return result
|
return result
|
||||||
|
@ -522,9 +512,7 @@ class FileManager:
|
||||||
except self.server.error:
|
except self.server.error:
|
||||||
# Attempt to start print failed
|
# Attempt to start print failed
|
||||||
start_print = False
|
start_print = False
|
||||||
rel_dir_path = os.path.dirname(upload_info['filename'])
|
await self.notify_sync_lock.wait(300.)
|
||||||
if not self.has_hidden_dir(rel_dir_path):
|
|
||||||
await self.notify_sync_lock.wait(300.)
|
|
||||||
self.notify_sync_lock = None
|
self.notify_sync_lock = None
|
||||||
return {
|
return {
|
||||||
'item': {
|
'item': {
|
||||||
|
@ -540,9 +528,7 @@ class FileManager:
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
self.notify_sync_lock = NotifySyncLock(upload_info['dest_path'])
|
self.notify_sync_lock = NotifySyncLock(upload_info['dest_path'])
|
||||||
self._process_uploaded_file(upload_info)
|
self._process_uploaded_file(upload_info)
|
||||||
rel_dir_path = os.path.dirname(upload_info['filename'])
|
await self.notify_sync_lock.wait(5.)
|
||||||
if not self.has_hidden_dir(rel_dir_path):
|
|
||||||
await self.notify_sync_lock.wait(5.)
|
|
||||||
self.notify_sync_lock = None
|
self.notify_sync_lock = None
|
||||||
return {
|
return {
|
||||||
'item': {
|
'item': {
|
||||||
|
@ -1197,8 +1183,8 @@ class INotifyHandler:
|
||||||
evt: InotifyEvent,
|
evt: InotifyEvent,
|
||||||
node: InotifyNode
|
node: InotifyNode
|
||||||
) -> None:
|
) -> None:
|
||||||
if evt.name and evt.name[0] == ".":
|
if evt.name in ['.', ".."]:
|
||||||
# ignore changes to the hidden directories
|
# ignore events for self and parent
|
||||||
return
|
return
|
||||||
root = node.get_root()
|
root = node.get_root()
|
||||||
node_path = node.get_path()
|
node_path = node.get_path()
|
||||||
|
|
Loading…
Reference in New Issue