@@ -121,7 +121,10 @@ def _move_recursive(self, old_path: str, new_path: str, path_mgr: Any = os.path)
121
121
for record in records :
122
122
id , old_recpath = record
123
123
new_recpath = path_mgr .join (new_path , path_mgr .relpath (old_recpath , start = old_path ))
124
- self .con .execute ("UPDATE Files SET path = ? WHERE id = ?" , (new_recpath , id ))
124
+ try :
125
+ self .con .execute ("UPDATE Files SET path = ? WHERE id = ?" , (new_recpath , id ))
126
+ except Exception as err :
127
+ self .log .error (err )
125
128
126
129
def _copy_recursive (self , from_path : str , to_path : str , path_mgr : Any = os .path ) -> None :
127
130
"""Copy all children of a given directory at `from_path` to a new
@@ -134,9 +137,12 @@ def _copy_recursive(self, from_path: str, to_path: str, path_mgr: Any = os.path)
134
137
for record in records :
135
138
(from_recpath ,) = record
136
139
to_recpath = path_mgr .join (to_path , path_mgr .relpath (from_recpath , start = from_path ))
137
- self .con .execute (
138
- "INSERT INTO Files (id, path) VALUES (?, ?)" , (self ._uuid (), to_recpath )
139
- )
140
+ try :
141
+ self .con .execute (
142
+ "INSERT INTO Files (id, path) VALUES (?, ?)" , (self ._uuid (), to_recpath )
143
+ )
144
+ except Exception as err :
145
+ self .log .error (err )
140
146
141
147
def _delete_recursive (self , path : str , path_mgr : Any = os .path ) -> None :
142
148
"""Delete all children of a given directory, delimited by `sep`."""
@@ -313,7 +319,10 @@ def _from_normalized_path(self, path: Optional[str]) -> Optional[str]:
313
319
def _create (self , path : str ) -> str :
314
320
path = self ._normalize_path (path )
315
321
id = self ._uuid ()
316
- self .con .execute ("INSERT INTO Files (id, path) VALUES (?, ?)" , (id , path ))
322
+ try :
323
+ self .con .execute ("INSERT INTO Files (id, path) VALUES (?, ?)" , (id , path ))
324
+ except Exception as err :
325
+ self .log .error (err )
317
326
return id
318
327
319
328
def index (self , path : str ) -> str :
@@ -346,7 +355,10 @@ def move(self, old_path: str, new_path: str) -> None:
346
355
id = row and row [0 ]
347
356
348
357
if id :
349
- self .con .execute ("UPDATE Files SET path = ? WHERE path = ?" , (new_path , old_path ))
358
+ try :
359
+ self .con .execute ("UPDATE Files SET path = ? WHERE path = ?" , (new_path , old_path ))
360
+ except Exception as err :
361
+ self .log .error (err )
350
362
self ._move_recursive (old_path , new_path , posixpath )
351
363
else :
352
364
id = self ._create (new_path )
@@ -673,10 +685,13 @@ def _create(self, path, stat_info):
673
685
have a unique `ino`.
674
686
"""
675
687
id = self ._uuid ()
676
- self .con .execute (
677
- "INSERT INTO Files (id, path, ino, crtime, mtime, is_dir) VALUES (?, ?, ?, ?, ?, ?)" ,
678
- (id , path , stat_info .ino , stat_info .crtime , stat_info .mtime , stat_info .is_dir ),
679
- )
688
+ try :
689
+ self .con .execute (
690
+ "INSERT INTO Files (id, path, ino, crtime, mtime, is_dir) VALUES (?, ?, ?, ?, ?, ?)" ,
691
+ (id , path , stat_info .ino , stat_info .crtime , stat_info .mtime , stat_info .is_dir ),
692
+ )
693
+ except Exception as err :
694
+ self .log .error (err )
680
695
return id
681
696
682
697
def _update (self , id , stat_info = None , path = None ):
@@ -694,26 +709,29 @@ def _update(self, id, stat_info=None, path=None):
694
709
dangerous and may throw a runtime error if the file is not guaranteed to
695
710
have a unique `ino`.
696
711
"""
697
- if stat_info and path :
698
- self .con .execute (
699
- "UPDATE Files SET ino = ?, crtime = ?, mtime = ?, path = ? WHERE id = ?" ,
700
- (stat_info .ino , stat_info .crtime , stat_info .mtime , path , id ),
701
- )
702
- return
703
-
704
- if stat_info :
705
- self .con .execute (
706
- "UPDATE Files SET ino = ?, crtime = ?, mtime = ? WHERE id = ?" ,
707
- (stat_info .ino , stat_info .crtime , stat_info .mtime , id ),
708
- )
709
- return
710
-
711
- if path :
712
- self .con .execute (
713
- "UPDATE Files SET path = ? WHERE id = ?" ,
714
- (path , id ),
715
- )
716
- return
712
+ try :
713
+ if stat_info and path :
714
+ self .con .execute (
715
+ "UPDATE Files SET ino = ?, crtime = ?, mtime = ?, path = ? WHERE id = ?" ,
716
+ (stat_info .ino , stat_info .crtime , stat_info .mtime , path , id ),
717
+ )
718
+ return
719
+
720
+ if stat_info :
721
+ self .con .execute (
722
+ "UPDATE Files SET ino = ?, crtime = ?, mtime = ? WHERE id = ?" ,
723
+ (stat_info .ino , stat_info .crtime , stat_info .mtime , id ),
724
+ )
725
+ return
726
+
727
+ if path :
728
+ self .con .execute (
729
+ "UPDATE Files SET path = ? WHERE id = ?" ,
730
+ (path , id ),
731
+ )
732
+ return
733
+ except Exception as err :
734
+ self .log .error (err )
717
735
718
736
def index (self , path , stat_info = None , commit = True ):
719
737
"""Returns the file ID for the file at `path`, creating a new file ID if
0 commit comments