Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-storage
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Platform
Development
swh-storage
Commits
b8aa5c4a
Commit
b8aa5c4a
authored
9 years ago
by
Nicolas Dandrimont
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into directory-listing-arrays
parents
8f97c011
e9f08de3
No related branches found
Branches containing commit
Tags
v1.4.1
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/storage/storage.py
+14
-8
14 additions, 8 deletions
swh/storage/storage.py
with
14 additions
and
8 deletions
swh/storage/storage.py
+
14
−
8
View file @
b8aa5c4a
...
...
@@ -92,8 +92,8 @@ class Storage():
content_filtered
=
sorted
((
cont
for
cont
in
content
if
cont
[
'
sha1
_git
'
]
not
in
missing_content
),
key
=
itemgetter
(
'
sha1
_git
'
))
if
cont
[
'
sha1
'
]
in
missing_content
),
key
=
itemgetter
(
'
sha1
'
))
db
.
copy_to
(
content_filtered
,
'
tmp_content
'
,
[
'
sha1
'
,
'
sha1_git
'
,
'
sha256
'
,
'
length
'
],
...
...
@@ -103,7 +103,7 @@ class Storage():
db
.
content_add_from_temp
(
cur
)
@db_transaction_generator
def
content_missing
(
self
,
content
,
cur
):
def
content_missing
(
self
,
content
,
key_hash
=
'
sha1
'
,
cur
=
None
):
"""
List content missing from storage
Args:
...
...
@@ -111,9 +111,10 @@ class Storage():
checksum algorithm in swh.core.hashutil.ALGORITHMS, mapped to
the corresponding checksum, and a length key mapped to the
content length.
key_hash: the name of the hash used as key (default:
'
sha1
'
)
Returns:
an iterable of
sha1
s missing from the storage
an iterable of
`key_hash`e
s missing from the storage
Raises:
TODO: an exception when we get a hash collision.
...
...
@@ -121,15 +122,20 @@ class Storage():
"""
db
=
self
.
db
keys
=
[
'
sha1
'
,
'
sha1_git
'
,
'
sha256
'
]
if
key_hash
not
in
keys
:
raise
ValueError
(
"
key_hash should be one of %s
"
%
keys
)
key_hash_idx
=
keys
.
index
(
key_hash
)
# Create temporary table for metadata injection
db
.
mktemp
(
'
content
'
,
cur
)
db
.
copy_to
(
content
,
'
tmp_content
'
,
[
'
sha1
'
,
'
sha1_git
'
,
'
sha256
'
,
'
length
'
],
cur
)
db
.
copy_to
(
content
,
'
tmp_content
'
,
keys
+
[
'
length
'
],
cur
)
for
obj
in
db
.
content_missing_from_temp
(
cur
):
yield
obj
[
0
]
yield
obj
[
key_hash_idx
]
def
directory_add
(
self
,
directories
):
"""
Add directories to the storage
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment