Commit 0ee01e2e authored by Florian Pritz's avatar Florian Pritz
Browse files

Keep using first used identifier when pkgname casing changes


Signed-off-by: Florian Pritz's avatarFlorian Pritz <bluewind@xinu.at>
parent 77aa28d2
......@@ -22,6 +22,10 @@ class DB:
c.execute('drop table files_old;')
self._set_version(2)
if version < 3:
c.execute('create table archive_identifier_aliases (from_identifier text, identifier text, primary key (`from_identifier`)) without rowid;')
self._set_version(3)
self.db.commit()
def _get_version(self):
......@@ -36,6 +40,22 @@ class DB:
(filename,))
self.db.commit()
def add_item_identifier(self, identifier):
c = self.db.cursor()
c.execute('insert into archive_identifier_aliases (from_identifier, identifier) values (?, ?)',
(identifier.lower(), identifier))
self.db.commit()
def get_item_identifier(self, identifier):
c = self.db.cursor()
c.execute('select identifier from archive_identifier_aliases where from_identifier = ?', (identifier.lower(),))
row = c.fetchone()
if row is not None:
return row['identifier']
else:
self.add_item_identifier(identifier)
return self.get_item_identifier(identifier)
def exists(self, filename):
c = self.db.cursor()
c.execute('select uploaded from files where filename = ?', (filename,))
......
......@@ -73,6 +73,10 @@ class ArchiveUploader:
metadata['description'] = ArchiveUploader.DESCRIPTION.format(pkgname=pkgname, pkgdesc=pkgdesc, url=pkginfo['url'], license=pkginfo['license'])
metadata['rights'] = 'License: ' + pkginfo['license']
# archive.org requires case-insensitively unique identifiers, but
# doesn't perform the mapping themselves. Thus, we do it here.
identifier = self.db.get_item_identifier(identifier)
for files in chunker(all_files, self.chunksize):
try:
res = self.ia.upload(identifier, files=files, metadata=metadata)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment