Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
s3storage
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
cubicweb
cubes
s3storage
Commits
32155eb4ba51
Commit
32155eb4ba51
authored
2 years ago
by
Efflam Lemaillet
Browse files
Options
Downloads
Patches
Plain Diff
add version id to entity
#13
parent
3a2b326e89cc
No related branches found
No related tags found
No related merge requests found
Pipeline
#152105
failed
2 years ago
Stage: lint
Stage: tests
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cubicweb_s3storage/storages.py
+13
-4
13 additions, 4 deletions
cubicweb_s3storage/storages.py
with
13 additions
and
4 deletions
cubicweb_s3storage/storages.py
+
13
−
4
View file @
32155eb4
...
@@ -87,10 +87,6 @@
...
@@ -87,10 +87,6 @@
else
:
else
:
oldkey
=
self
.
get_s3_key
(
entity
,
attr
)
oldkey
=
self
.
get_s3_key
(
entity
,
attr
)
key
=
self
.
new_s3_key
(
entity
,
attr
)
key
=
self
.
new_s3_key
(
entity
,
attr
)
# save S3 key
entity
.
cw_edited
.
edited_attribute
(
attr
,
Binary
(
key
.
encode
(
'
utf-8
'
)))
# copy Binary value, workaround for boto3 bug
# copy Binary value, workaround for boto3 bug
# https://github.com/boto/s3transfer/issues/80
# https://github.com/boto/s3transfer/issues/80
# .read() is required since Binary can't wrap itself
# .read() is required since Binary can't wrap itself
...
@@ -109,6 +105,9 @@
...
@@ -109,6 +105,9 @@
**
extra_args
)
**
extra_args
)
buffer
.
close
()
buffer
.
close
()
# save S3 key
self
.
save_s3_key
(
entity
,
attr
,
s3_object
.
key
,
s3_object
.
value
)
# when key is suffixed, move to final key in post commit event
# when key is suffixed, move to final key in post commit event
# remove temporary key on rollback
# remove temporary key on rollback
S3AddFileOp
.
get_instance
(
entity
.
_cw
).
add_data
(
S3AddFileOp
.
get_instance
(
entity
.
_cw
).
add_data
(
...
@@ -160,6 +159,16 @@
...
@@ -160,6 +159,16 @@
source
.
doexec
(
cnx
,
sql
,
attrs
)
source
.
doexec
(
cnx
,
sql
,
attrs
)
entity
.
cw_edited
=
None
entity
.
cw_edited
=
None
def
save_s3_key
(
self
,
entity
,
attr
,
key
,
version_id
=
None
):
if
entity
.
_cw
.
repo
.
config
[
'
s3-activate-object-versioning
'
]
\
and
version_id
is
not
None
:
id_string
=
(
key
,
version_id
).
__repr__
()
else
:
id_string
=
key
entity
.
cw_edited
.
edited_attribute
(
attr
,
Binary
(
id_string
.
encode
(
'
utf-8
'
)))
def
get_s3_key
(
self
,
entity
,
attr
):
def
get_s3_key
(
self
,
entity
,
attr
):
"""
"""
Return the S3 key of the S3 object storing the content of attribute
Return the S3 key of the S3 object storing the content of attribute
...
...
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