Skip to content

Commit 9b8e061

Browse files
committed
protect against duplicate files in the database
1 parent b381d6e commit 9b8e061

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

stag

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,12 @@ class StagFS(Operations):
823823
else:
824824
tags = ""
825825

826+
# the user might be trying to create a file with the same name as another file, but in a different subfolder
827+
# this wouldn't trigger a conflict in getattr and it would still call create
828+
# here we double check to make sure no such file exist and avoid creating duplicates
829+
if os.path.exists(real_path):
830+
raise FuseOSError(errno.EEXIST)
831+
826832
# add the file to the database
827833
self.cur.execute(f"INSERT INTO files VALUES ('{basename}', '{tags}')")
828834
self.con.commit()

0 commit comments

Comments
 (0)