Skip to content

Commit 67595fa

Browse files
feiniks杨赫然
andauthored
Add get_container_name func (#88)
* Add get_container_name func * Add get_container_name func --------- Co-authored-by: 杨赫然 <[email protected]>
1 parent e971c15 commit 67595fa

File tree

6 files changed

+22
-0
lines changed

6 files changed

+22
-0
lines changed

seafobj/backends/alioss.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class SeafObjStoreOSS(AbstractObjStore):
88
def __init__(self, compressed, oss_conf, crypto=None, cache=None):
99
AbstractObjStore.__init__(self, compressed, crypto, cache)
1010
self.oss_client = SeafOSSClient(oss_conf)
11+
self.bucket_name = oss_conf.bucket_name
1112

1213
def read_obj_raw(self, repo_id, version, obj_id):
1314
real_obj_id = '%s/%s' % (repo_id, obj_id)
@@ -44,3 +45,6 @@ def stat_raw(self, repo_id, obj_id):
4445
key = '%s/%s' % (repo_id, obj_id)
4546

4647
return self.oss_client.stat_obj(key)
48+
49+
def get_container_name(self):
50+
return self.bucket_name

seafobj/backends/base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,6 @@ def stat(self, repo_id, verison, obj_id):
8383

8484
def stat_raw(self, repo_id, obj_id):
8585
raise NotImplementedError
86+
87+
def get_container_name(self):
88+
raise NotImplementedError

seafobj/backends/ceph.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class SeafObjStoreCeph(AbstractObjStore):
7272
def __init__(self, compressed, ceph_conf, crypto=None, cache=None):
7373
AbstractObjStore.__init__(self, compressed, crypto, cache)
7474
self.ceph_client = SeafCephClient(ceph_conf)
75+
self.pool_name = ceph_conf.pool_name
7576

7677
def read_obj_raw(self, repo_id, version, obj_id):
7778
data = self.ceph_client.read_object_content(repo_id, obj_id)
@@ -129,3 +130,6 @@ def stat_raw(self, repo_id, obj_id):
129130
raise
130131
finally:
131132
self.ceph_client.ioctx_pool.return_ioctx(ioctx)
133+
134+
def get_container_name(self):
135+
return self.pool_name

seafobj/backends/filesystem.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,6 @@ def stat_raw(self, repo_id, obj_id):
9898
if not stat_info:
9999
return -1
100100
return stat_info.st_size
101+
102+
def get_container_name(self):
103+
return self.obj_dir

seafobj/backends/s3.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class SeafObjStoreS3(AbstractObjStore):
99
def __init__(self, compressed, s3_conf, crypto=None, cache=None):
1010
AbstractObjStore.__init__(self, compressed, crypto, cache)
1111
self.s3_client = SeafS3Client(s3_conf)
12+
self.bucket_name = s3_conf.bucket_name
1213

1314
def read_obj_raw(self, repo_id, version, obj_id):
1415
real_obj_id = '%s/%s' % (repo_id, obj_id)
@@ -41,3 +42,6 @@ def remove_obj(self, repo_id, obj_id):
4142
def stat_raw(self, repo_id, obj_id):
4243
s3_path = '%s/%s' % (repo_id, obj_id)
4344
return self.s3_client.stat_obj(s3_path)
45+
46+
def get_container_name(self):
47+
return self.bucket_name

seafobj/backends/swift.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ class SeafObjStoreSwift(AbstractObjStore):
291291
def __init__(self, compressed, swift_conf, crypto=None, cache=None):
292292
AbstractObjStore.__init__(self, compressed, crypto, cache)
293293
self.swift_client = SeafSwiftClient(swift_conf)
294+
self.container = swift_conf.container
294295

295296
def read_obj_raw(self, repo_id, version, obj_id):
296297
real_obj_id = '%s/%s' % (repo_id, obj_id)
@@ -322,3 +323,6 @@ def stat_raw(self, repo_id, obj_id):
322323
key = '%s/%s' % (repo_id, obj_id)
323324

324325
return self.swift_client.stat_obj(key)
326+
327+
def get_container_name(self):
328+
return self.container

0 commit comments

Comments
 (0)