Author: Dennis Lee Bieber
Posted: 2012-05-03 at 21:32:57
On Thu, 03 May 2012 20:07:00 -0500, Bill House
<wch-tech@house-grp.net> declaimed the
following in gmane.comp.python.dabo.user:
> Thanks for taking a look at this guys.
>
> The file is sorted(indexed) md5sum + path + file_name
>
> Therefore the longer path name (and more deeply nested) will be the last
> one and therefore the one retained.
> (That was my plan anyway.)
>
> No file removal will be done at this stage, the Boolean field "del" will
> be marked as true and then on another pass (after the results are
> inspected), the files belonging to the records marked for deletion will
> be moved (not deleted) to another place where another inspection will
> take place and after the unmoved files are backed up the moved files
> will be deleted.
>
So go back to my example in which the duplicate /records/ were
deleted from the database, and change it to perform an update...
#pseudo code including raw database operations
csr = con.cursor() #get a cursor for the database connection
csr.execute("""select md5sum, path, file_name
from files
order by md5sum desc,
path desc,
file_name desc""")
lastMD5 = None
for (md5sum, path, file_name) in csr.fetchall():
#I'm not sure if you can issue a new
#command on the cursor before
#reading all the data, so fetchall() reads all
if md5sum == lastMD5:
#substitute the appropriate placeholder;
#MySQLdb uses %s, SQLite3 uses ?
csr.execute("""update files set
flag = True
where
md5sum = %s and
path = %s and
file_name = %s""",
(md5sum, path, file_name))
else:
lastMD5 = md5sum
csr.close()
con.commit() #all the flag updates now happen
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
_______________________________________________
Post Messages to: Dabo-users@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/rkf6q7pi57ckvtnrajrap7g4sh5t1p52du@invalid.netcom.com