Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Arch Linux
arch-historical-archive
Commits
0ee01e2e
Commit
0ee01e2e
authored
Apr 28, 2019
by
Florian Pritz
Browse files
Keep using first used identifier when pkgname casing changes
Signed-off-by:
Florian Pritz
<
bluewind@xinu.at
>
parent
77aa28d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
DB.py
View file @
0ee01e2e
...
...
@@ -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
,))
...
...
upload_pkg_internetarchive.py
View file @
0ee01e2e
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment