Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-archiver
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Platform
Development
swh-archiver
Commits
54ec2fca
Commit
54ec2fca
authored
8 years ago
by
Antoine R. Dumont
Browse files
Options
Downloads
Patches
Plain Diff
Improve get_contents_error implementation
- Only read the storage key once. - Improve the logging error.
parent
b3c109e4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/archiver/worker.py
+12
-10
12 additions, 10 deletions
swh/archiver/worker.py
with
12 additions
and
10 deletions
swh/archiver/worker.py
+
12
−
10
View file @
54ec2fca
...
@@ -164,33 +164,35 @@ class BaseArchiveWorker(config.SWHConfig, metaclass=abc.ABCMeta):
...
@@ -164,33 +164,35 @@ class BaseArchiveWorker(config.SWHConfig, metaclass=abc.ABCMeta):
self
.
content_archive_update
(
self
.
content_archive_update
(
content_id
,
archive_id
=
destination
,
new_status
=
'
present
'
)
content_id
,
archive_id
=
destination
,
new_status
=
'
present
'
)
def
get_contents_error
(
self
,
content_ids
,
storage
):
def
get_contents_error
(
self
,
content_ids
,
source_
storage
):
"""
Indicates what is the error associated to a content when needed
"""
Indicates what is the error associated to a content when needed
Check the given content on the given storage. If an error is detected,
Check the given content on the given storage. If an error is detected,
it will be reported through the returned dict.
it will be reported through the returned dict.
Args:
Args:
content_ids ([sha1]): list of content ids to check
content_ids ([sha1]): list of content ids to check
storage (str): the storage where are the content to check.
source_storage (str): the source storage holding the
contents to check.
Returns:
Returns:
a dict that map {content_id -> error_status} for each content_id
a dict that map {content_id -> error_status} for each content_id
with an error. The `error_status` result may be
'
missing
'
or
with an error. The `error_status` result may be
'
missing
'
or
'
corrupted
'
.
'
corrupted
'
.
"""
"""
content_status
=
{}
content_status
=
{}
storage
=
self
.
objstorages
[
source_storage
]
for
content_id
in
content_ids
:
for
content_id
in
content_ids
:
try
:
try
:
s
elf
.
objstorages
[
storage
]
.
check
(
content_id
)
s
torage
.
check
(
content_id
)
except
Error
as
e
:
except
Error
:
content_status
[
content_id
]
=
'
corrupted
'
content_status
[
content_id
]
=
'
corrupted
'
content_id
=
hashutil
.
hash_to_hex
(
content_id
)
logger
.
error
(
'
%s corrupted!
'
%
hashutil
.
hash_to_hex
(
logger
.
error
(
e
)
content_id
)
)
except
ObjNotFoundError
as
e
:
except
ObjNotFoundError
:
content_status
[
content_id
]
=
'
missing
'
content_status
[
content_id
]
=
'
missing
'
content_id
=
hashutil
.
hash_to_hex
(
content_id
)
logger
.
error
(
'
%s missing!
'
%
hashutil
.
hash_to_hex
(
content_id
))
logger
.
error
(
e
)
return
content_status
return
content_status
...
...
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