added check for duplicates in tables TAGS and CATEGORY
This commit is contained in:
parent
e169cf1b6b
commit
73904fac53
20
image-index
20
image-index
|
@ -179,6 +179,9 @@ class database():
|
|||
n=0
|
||||
for i in self.get_col(typ):
|
||||
aliases=[]
|
||||
if i == "." and self.name == "FILES":
|
||||
print("NO ENTRIES IN THE INDEX!")
|
||||
return "."
|
||||
# get aliases for the checks, but only for unspecific search!
|
||||
if self.name == "FILES":
|
||||
if typ == "*":
|
||||
|
@ -278,6 +281,15 @@ class metatable(database):
|
|||
selection=self.select_index(selection,quiet)
|
||||
return selection
|
||||
|
||||
def update_index(self, typ, update, where, val):
|
||||
selection=self.search_index(update,"strict")
|
||||
if selection[0] != "." and len(selection) >= 1:
|
||||
print("One entry is already called {}!".format(update))
|
||||
return False
|
||||
else:
|
||||
super().update_index(typ, update, where, val)
|
||||
return True
|
||||
|
||||
class filestable(database):
|
||||
def __init__(self,filepath = CONFIG_DIR + "/index.db"):
|
||||
self.name="FILES"
|
||||
|
@ -470,7 +482,7 @@ class filestable(database):
|
|||
|
||||
return self.select_index(selection,quiet)
|
||||
|
||||
def get_randhex(self,count=5):
|
||||
def get_randhex(count=5):
|
||||
randhex=""
|
||||
for i in range(count):
|
||||
randhex+=random.choice("0123456789abcdef")
|
||||
|
@ -668,16 +680,16 @@ def meta_update(typ,args):
|
|||
sel_list=ctb.search_index(search)
|
||||
for item in sel_list:
|
||||
alias=ctb.get_alias(item[0])
|
||||
ctb.update_index("ALIAS", update, "NAME", item[0])
|
||||
success=ctb.update_index("ALIAS", update, "NAME", item[0])
|
||||
elif re.match('[tT].*',typ):
|
||||
sel_list=ttb.search_index(search)
|
||||
for item in sel_list:
|
||||
alias=ttb.get_alias(item[0])
|
||||
ttb.update_index("ALIAS", update, "NAME", item[0])
|
||||
success=ttb.update_index("ALIAS", update, "NAME", item[0])
|
||||
else:
|
||||
print("The first argument needs to be either 'Category' or 'Tags'!")
|
||||
return 1
|
||||
if item[0] != ".":
|
||||
if item[0] != "." and success:
|
||||
print("Updated {} to {}".format(alias,update))
|
||||
|
||||
def meta_help():
|
||||
|
|
Loading…
Reference in a new issue