Hello,
I believe that I have now fixed the last two issues with history
numbering. The fact is that the "num" field on the history table *must*
be contiguous. This is assumed in many places in the code.
The last fixes was in the copy&paste.
There is one remaining issue not yet merged:
https://github.com/darktable-org/darktable/pull/909
(I really believe that this should be merged sooner than later)
On my side to fix my database I have used the attached Python script.
I'm not sure how to handle those issues for all users on the next
release.
I'm sure that the current release 1.6.6 is affected by this.
Comment welcomed!
--
Pascal Obry / Magny Les Hameaux (78)
The best way to travel is by means of imagination
http://v2p.fr.eu.org
http://www.obry.net
gpg --keyserver keys.gnupg.net --recv-key F949BD3B
#!/usr/bin/python
# this script is to be used to clean-up darktable history table.
# some bugs in older releases had a nasty effect to break a rule that the num
# on the history table must start to 0 and increment one by one (without gap)
# for each applied iop.
#
# this script will detect this and will restore the proper values.
import sqlite3
# CAUTION: set to True by default as in this case there is no change
# done on the database. The set of UPDATEs are only written
# to the console to be checked.
check_only=True
# Change MYNAME to your actual login or full path to the library.db database
DB="/home/<MYNAME>/.config/darktable/library.db"
images=[]
conn = sqlite3.connect(DB)
# check that num values are contiguous for each image's history. if not
# record the offending image's id into images set.
def check_for_update():
global images
c = conn.cursor()
imgid=-1
num=-1
for row in c.execute('SELECT imgid,num FROM history ORDER BY imgid,num'):
if row[0] != imgid:
imgid=row[0]
num=0
if num != row[1]:
print("-- Wrong ordering for image %d at num %d" % (imgid, num))
if imgid not in images:
images = images + [imgid]
num = num + 1
# restore proper continuous value for imgid
def update_imgid(imgid):
c = conn.cursor()
updates=[]
num=0
for row in c.execute('SELECT rowid FROM history WHERE imgid=%d ORDER BY rowid' % imgid):
updates = updates + ["UPDATE history SET num=%d WHERE rowid=%d"
% (num,row[0])]
num = num + 1
for u in updates:
if check_only:
print("%s;" % u)
else:
c.execute(u)
conn.commit()
# do the check
check_for_update()
# for any images found to be wrong, do update
for key in images:
update_imgid(key)
print("-- %d" % key)
c = conn.cursor()
if check_only:
print("UPDATE images SET history_end=(SELECT MAX(num)+1 FROM history WHERE imgid=id;")
print("%d images are to be restored" % len(images))
else:
c.execute("UPDATE images SET history_end=(SELECT MAX(num)+1 FROM history WHERE imgid=id)")
print("%d images have been updated." % len(images))
conn.commit()
conn.close()
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
darktable-devel mailing list
darktable-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/darktable-devel