Skip to content

Commit

Permalink
Add get_container_name func (#88)
Browse files Browse the repository at this point in the history
* Add get_container_name func

* Add get_container_name func

---------

Co-authored-by: 杨赫然 <[email protected]>
  • Loading branch information
feiniks and 杨赫然 authored Oct 30, 2024
1 parent e971c15 commit 67595fa
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions seafobj/backends/alioss.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class SeafObjStoreOSS(AbstractObjStore):
def __init__(self, compressed, oss_conf, crypto=None, cache=None):
AbstractObjStore.__init__(self, compressed, crypto, cache)
self.oss_client = SeafOSSClient(oss_conf)
self.bucket_name = oss_conf.bucket_name

def read_obj_raw(self, repo_id, version, obj_id):
real_obj_id = '%s/%s' % (repo_id, obj_id)
Expand Down Expand Up @@ -44,3 +45,6 @@ def stat_raw(self, repo_id, obj_id):
key = '%s/%s' % (repo_id, obj_id)

return self.oss_client.stat_obj(key)

def get_container_name(self):
return self.bucket_name
3 changes: 3 additions & 0 deletions seafobj/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,6 @@ def stat(self, repo_id, verison, obj_id):

def stat_raw(self, repo_id, obj_id):
raise NotImplementedError

def get_container_name(self):
raise NotImplementedError
4 changes: 4 additions & 0 deletions seafobj/backends/ceph.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class SeafObjStoreCeph(AbstractObjStore):
def __init__(self, compressed, ceph_conf, crypto=None, cache=None):
AbstractObjStore.__init__(self, compressed, crypto, cache)
self.ceph_client = SeafCephClient(ceph_conf)
self.pool_name = ceph_conf.pool_name

def read_obj_raw(self, repo_id, version, obj_id):
data = self.ceph_client.read_object_content(repo_id, obj_id)
Expand Down Expand Up @@ -129,3 +130,6 @@ def stat_raw(self, repo_id, obj_id):
raise
finally:
self.ceph_client.ioctx_pool.return_ioctx(ioctx)

def get_container_name(self):
return self.pool_name
3 changes: 3 additions & 0 deletions seafobj/backends/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,6 @@ def stat_raw(self, repo_id, obj_id):
if not stat_info:
return -1
return stat_info.st_size

def get_container_name(self):
return self.obj_dir
4 changes: 4 additions & 0 deletions seafobj/backends/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class SeafObjStoreS3(AbstractObjStore):
def __init__(self, compressed, s3_conf, crypto=None, cache=None):
AbstractObjStore.__init__(self, compressed, crypto, cache)
self.s3_client = SeafS3Client(s3_conf)
self.bucket_name = s3_conf.bucket_name

def read_obj_raw(self, repo_id, version, obj_id):
real_obj_id = '%s/%s' % (repo_id, obj_id)
Expand Down Expand Up @@ -41,3 +42,6 @@ def remove_obj(self, repo_id, obj_id):
def stat_raw(self, repo_id, obj_id):
s3_path = '%s/%s' % (repo_id, obj_id)
return self.s3_client.stat_obj(s3_path)

def get_container_name(self):
return self.bucket_name
4 changes: 4 additions & 0 deletions seafobj/backends/swift.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ class SeafObjStoreSwift(AbstractObjStore):
def __init__(self, compressed, swift_conf, crypto=None, cache=None):
AbstractObjStore.__init__(self, compressed, crypto, cache)
self.swift_client = SeafSwiftClient(swift_conf)
self.container = swift_conf.container

def read_obj_raw(self, repo_id, version, obj_id):
real_obj_id = '%s/%s' % (repo_id, obj_id)
Expand Down Expand Up @@ -322,3 +323,6 @@ def stat_raw(self, repo_id, obj_id):
key = '%s/%s' % (repo_id, obj_id)

return self.swift_client.stat_obj(key)

def get_container_name(self):
return self.container

0 comments on commit 67595fa

Please sign in to comment.