- q = session.execute("""
-SELECT s.id, s.file, f.filename
- FROM source s
- LEFT JOIN files f
- ON (s.file = f.id)
- WHERE f.last_used IS NULL
- AND s.id NOT IN
- (SELECT sa.source FROM src_associations sa)
- AND s.id NOT IN
- (SELECT b.source FROM binaries b)
- AND s.id NOT IN (SELECT esr.src_id FROM extra_src_references esr)
- AND f.id NOT IN
- (SELECT bqf.fileid FROM build_queue_files bqf)""")
-
- #### XXX: this should ignore cases where the files for the binary b
- #### have been marked for deletion (so the delay between bins go
- #### byebye and sources go byebye is 0 instead of StayOfExecution)
-
- for i in q.fetchall():
- source_id = i[0]
- dsc_file_id = i[1]
- dsc_fname = i[2]
-
- # Mark the .dsc file for deletion
- Logger.log(["set lastused", dsc_fname])
- if not Options["No-Action"]:
- session.execute("""UPDATE files SET last_used = :last_used
- WHERE id = :dscfileid AND last_used IS NULL""",
- {'last_used': now_date, 'dscfileid': dsc_file_id})
-
- # Mark all other files references by .dsc too if they're not used by anyone else
- x = session.execute("""SELECT f.id, f.filename FROM files f, dsc_files d
- WHERE d.source = :sourceid AND d.file = f.id""",
- {'sourceid': source_id})
- for j in x.fetchall():
- file_id = j[0]
- file_name = j[1]
- y = session.execute("SELECT id FROM dsc_files d WHERE d.file = :fileid", {'fileid': file_id})
- if len(y.fetchall()) == 1:
- Logger.log(["set lastused", file_name])
- if not Options["No-Action"]:
- session.execute("""UPDATE files SET last_used = :lastused
- WHERE id = :fileid AND last_used IS NULL""",
- {'lastused': now_date, 'fileid': file_id})
-
- if not Options["No-Action"]:
- session.commit()