Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
1858bd97
Commit
1858bd97
authored
6 years ago
by
yvesn
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-6427: obis - added support for git annex backend WORM
parent
692d5891
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/python/OBis/obis/dm/git.py
+28
-4
28 additions, 4 deletions
src/python/OBis/obis/dm/git.py
with
28 additions
and
4 deletions
src/python/OBis/obis/dm/git.py
+
28
−
4
View file @
1858bd97
...
@@ -167,14 +167,30 @@ class ChecksumGeneratorMd5(object):
...
@@ -167,14 +167,30 @@ class ChecksumGeneratorMd5(object):
return
hash_md5
.
hexdigest
()
return
hash_md5
.
hexdigest
()
class
ChecksumGeneratorWORM
(
object
):
def
get_checksum
(
self
,
file
):
return
{
'
checksum
'
:
self
.
worm
(
file
),
'
checksumType
'
:
'
WORM
'
,
'
fileLength
'
:
os
.
path
.
getsize
(
file
),
'
path
'
:
file
}
def
worm
(
self
,
file
):
modification_time
=
int
(
os
.
path
.
getmtime
(
file
))
size
=
os
.
path
.
getsize
(
file
)
return
"
WORM-s{}-m{}--{}
"
.
format
(
size
,
modification_time
,
file
)
class
ChecksumGeneratorGitAnnex
(
object
):
class
ChecksumGeneratorGitAnnex
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
backend
=
self
.
_get_annex_backend
()
self
.
backend
=
self
.
_get_annex_backend
()
self
.
checksum_generator_replacement
=
ChecksumGeneratorCrc32
()
if
backend
is
None
else
None
self
.
checksum_generator_replacement
=
ChecksumGeneratorCrc32
()
if
self
.
backend
is
None
else
None
# define which generator to use for files which are not handled by annex
# define which generator to use for files which are not handled by annex
if
backend
==
'
MD5
'
:
if
self
.
backend
==
'
MD5
'
:
self
.
checksum_generator_supplement
=
ChecksumGeneratorMd5
()
self
.
checksum_generator_supplement
=
ChecksumGeneratorMd5
()
elif
self
.
backend
==
'
WORM
'
:
self
.
checksum_generator_supplement
=
ChecksumGeneratorWORM
()
else
:
else
:
self
.
checksum_generator_supplement
=
ChecksumGeneratorCrc32
()
self
.
checksum_generator_supplement
=
ChecksumGeneratorCrc32
()
...
@@ -191,12 +207,20 @@ class ChecksumGeneratorGitAnnex(object):
...
@@ -191,12 +207,20 @@ class ChecksumGeneratorGitAnnex(object):
if
annex_info
[
'
present
'
]
!=
True
:
if
annex_info
[
'
present
'
]
!=
True
:
return
self
.
checksum_generator_supplement
.
get_checksum
(
file
)
return
self
.
checksum_generator_supplement
.
get_checksum
(
file
)
return
{
return
{
'
checksum
'
:
annex_info
[
'
key
'
].
split
(
'
--
'
)[
1
]
,
'
checksum
'
:
self
.
_get_checksum_from_annex_info
(
annex_info
)
,
'
checksumType
'
:
annex_info
[
'
key
'
].
split
(
'
-
'
)[
0
],
'
checksumType
'
:
annex_info
[
'
key
'
].
split
(
'
-
'
)[
0
],
'
fileLength
'
:
os
.
path
.
getsize
(
file
),
'
fileLength
'
:
os
.
path
.
getsize
(
file
),
'
path
'
:
file
'
path
'
:
file
}
}
def
_get_checksum_from_annex_info
(
self
,
annex_info
):
if
self
.
backend
==
'
MD5
'
:
return
annex_info
[
'
key
'
].
split
(
'
--
'
)[
1
]
elif
self
.
backend
==
'
WORM
'
:
return
annex_info
[
'
key
'
][
5
:]
else
:
raise
ValueError
(
"
Git annex backend not supported:
"
+
self
.
backend
)
def
_get_annex_backend
(
self
):
def
_get_annex_backend
(
self
):
with
open
(
'
.gitattributes
'
)
as
gitattributes
:
with
open
(
'
.gitattributes
'
)
as
gitattributes
:
for
line
in
gitattributes
.
readlines
():
for
line
in
gitattributes
.
readlines
():
...
...
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