Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
soledad
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
leap
soledad
Commits
d574e734
Verified
Commit
d574e734
authored
7 years ago
by
Victor
Browse files
Options
Downloads
Patches
Plain Diff
[feature] add implementation for get_blob_size
parent
5c810908
No related branches found
No related tags found
1 merge request
!166
Streaming blobs (Related: #8809 #8810 #8773 )
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/leap/soledad/server/_blobs.py
+2
-1
2 additions, 1 deletion
src/leap/soledad/server/_blobs.py
tests/blobs/test_fs_backend.py
+13
-0
13 additions, 0 deletions
tests/blobs/test_fs_backend.py
with
15 additions
and
1 deletion
src/leap/soledad/server/_blobs.py
+
2
−
1
View file @
d574e734
...
@@ -144,7 +144,8 @@ class FilesystemBlobsBackend(object):
...
@@ -144,7 +144,8 @@ class FilesystemBlobsBackend(object):
pass
pass
def
get_blob_size
(
self
,
user
,
blob_id
,
namespace
=
''
):
def
get_blob_size
(
self
,
user
,
blob_id
,
namespace
=
''
):
raise
NotImplementedError
blob_path
=
self
.
_get_path
(
user
,
blob_id
,
namespace
)
return
os
.
stat
(
blob_path
).
st_size
def
count
(
self
,
user
,
request
,
namespace
=
''
):
def
count
(
self
,
user
,
request
,
namespace
=
''
):
base_path
=
self
.
_get_path
(
user
,
namespace
=
namespace
)
base_path
=
self
.
_get_path
(
user
,
namespace
=
namespace
)
...
...
This diff is collapsed.
Click to expand it.
tests/blobs/test_fs_backend.py
+
13
−
0
View file @
d574e734
...
@@ -51,6 +51,19 @@ class FilesystemBackendTestCase(unittest.TestCase):
...
@@ -51,6 +51,19 @@ class FilesystemBackendTestCase(unittest.TestCase):
expected_method
.
assert_called_once_with
(
'
Tag
'
,
[
expected_tag
])
expected_method
.
assert_called_once_with
(
'
Tag
'
,
[
expected_tag
])
@pytest.mark.usefixtures
(
"
method_tmpdir
"
)
def
test_get_blob_size
(
self
):
# get a backend
backend
=
_blobs
.
FilesystemBlobsBackend
(
blobs_path
=
self
.
tempdir
)
# write a blob with size=10
path
=
backend
.
_get_path
(
'
user
'
,
'
blob_id
'
,
''
)
mkdir_p
(
os
.
path
.
split
(
path
)[
0
])
with
open
(
path
,
"
w
"
)
as
f
:
f
.
write
(
"
0123456789
"
)
# check it's size
size
=
backend
.
get_blob_size
(
'
user
'
,
'
blob_id
'
,
''
)
self
.
assertEquals
(
10
,
size
)
@pytest.mark.usefixtures
(
"
method_tmpdir
"
)
@pytest.mark.usefixtures
(
"
method_tmpdir
"
)
@mock.patch.object
(
_blobs
.
static
,
'
File
'
)
@mock.patch.object
(
_blobs
.
static
,
'
File
'
)
@mock.patch.object
(
_blobs
.
FilesystemBlobsBackend
,
'
_get_path
'
,
@mock.patch.object
(
_blobs
.
FilesystemBlobsBackend
,
'
_get_path
'
,
...
...
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