Delete file path entry in db when file is moved inside collection
This commit is contained in:
parent
1a78962012
commit
2ac8ca3b67
|
@ -287,7 +287,6 @@ class Collection(object):
|
||||||
row_data = {}
|
row_data = {}
|
||||||
for title in self.db.tables[table]['header']:
|
for title in self.db.tables[table]['header']:
|
||||||
key = utils.camel2snake(title)
|
key = utils.camel2snake(title)
|
||||||
# Convert Path type to str
|
|
||||||
row_data[title] = metadata[key]
|
row_data[title] = metadata[key]
|
||||||
|
|
||||||
return row_data
|
return row_data
|
||||||
|
@ -336,6 +335,10 @@ class Collection(object):
|
||||||
media.metadata['file_path'] = os.path.relpath(dest_path,
|
media.metadata['file_path'] = os.path.relpath(dest_path,
|
||||||
self.root)
|
self.root)
|
||||||
self._add_db_data(dest_path, media.metadata)
|
self._add_db_data(dest_path, media.metadata)
|
||||||
|
if self.mode == 'move':
|
||||||
|
# Delete file path entry in db when file is moved inside collection
|
||||||
|
if str(self.root) in str(src_path):
|
||||||
|
self.db.delete_filepath(str(src_path.relative_to(self.root)))
|
||||||
|
|
||||||
self.summary.append((src_path, dest_path))
|
self.summary.append((src_path, dest_path))
|
||||||
record = True
|
record = True
|
||||||
|
|
|
@ -259,17 +259,20 @@ class Sqlite:
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def delete_row(self, table, id):
|
def delete_row(self, table, column, value):
|
||||||
"""
|
"""
|
||||||
Delete a row by row id in table
|
Delete a row by row id in table
|
||||||
:param table: database table
|
:param table: database table
|
||||||
:param id: id of the row
|
:param id: id of the row
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
sql = f'delete from {table} where id=?'
|
sql = f'delete from {table} where {column}=?'
|
||||||
self.cur.execute(sql, (id,))
|
self.cur.execute(sql, (value,))
|
||||||
self.con.commit()
|
self.con.commit()
|
||||||
|
|
||||||
|
def delete_filepath(self, value):
|
||||||
|
self.delete_row('metadata', 'FilePath', value)
|
||||||
|
|
||||||
def delete_all_rows(self, table):
|
def delete_all_rows(self, table):
|
||||||
"""
|
"""
|
||||||
Delete all row in table
|
Delete all row in table
|
||||||
|
|
Loading…
Reference in New Issue