remote: RFC: unify changed_cache

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2018-12-20 22:09:26 +02:00
parent 141de1443c
commit 7758e53b35
5 changed files with 12 additions and 58 deletions
+12
View File
@@ -200,3 +200,15 @@ class RemoteBase(object):
self.remove(path_info)
removed = True
return removed
def changed_cache(self, checksum):
cache = self.checksum_to_path_info(checksum)
if {self.PARAM_CHECKSUM: checksum} != self.save_info(cache):
if self.exists(cache):
msg = 'Corrupted cache file {}'
logger.warn(msg.format(str(cache)))
self.remove(cache)
return True
return False
-13
View File
@@ -73,19 +73,6 @@ class RemoteGS(RemoteBase):
path_info['bucket'],
path_info['path'])
def changed_cache(self, md5):
path = self.checksum_to_path(md5)
cache = {'scheme': 'gs', 'bucket': self.bucket, 'path': path}
if {self.PARAM_CHECKSUM: md5} != self.save_info(cache):
if self.exists(cache):
msg = 'Corrupted cache file {}'
logger.warn(msg.format(self.to_string(cache)))
self.remove(cache)
return True
return False
def changed(self, path_info, checksum_info):
if not self.exists(path_info):
return True
-15
View File
@@ -88,21 +88,6 @@ class RemoteHDFS(RemoteBase):
return "{}://{}".format(path_info['scheme'],
path_info['path'])
def changed_cache(self, checksum):
cache = {}
cache['scheme'] = 'hdfs'
cache['user'] = self.user
cache['path'] = self.checksum_to_path(checksum)
if {self.PARAM_CHECKSUM: checksum} != self.save_info(cache):
if self.exists(cache):
msg = 'Corrupted cache file {}'
logger.warn(msg.format(self.to_string(cache)))
self.remove(cache)
return True
return False
def changed(self, path_info, checksum_info):
if not self.exists(path_info):
return True
-13
View File
@@ -138,19 +138,6 @@ class RemoteS3(RemoteBase):
def to_string(path_info):
return "s3://{}/{}".format(path_info['bucket'], path_info['path'])
def changed_cache(self, etag):
path = self.checksum_to_path(etag)
cache = {'scheme': 's3', 'bucket': self.bucket, 'path': path}
if {self.PARAM_CHECKSUM: etag} != self.save_info(cache):
if self.exists(cache):
msg = 'Corrupted cache file {}'
logger.warn(msg.format(self.to_string(cache)))
self.remove(cache)
return True
return False
def checkout(self, path_info, checksum_info):
if path_info['scheme'] != 's3':
raise NotImplementedError
-17
View File
@@ -234,23 +234,6 @@ class RemoteSSH(RemoteBase):
path_info['host'],
path_info['path'])
def changed_cache(self, md5):
cache = {}
cache['scheme'] = 'ssh'
cache['host'] = self.host
cache['port'] = self.port
cache['user'] = self.user
cache['path'] = self.checksum_to_path(md5)
if {self.PARAM_CHECKSUM: md5} != self.save_info(cache):
if self.exists(cache):
msg = 'Corrupted cache file {}'
logger.warn(msg.format(self.to_string(cache)))
self.remove(cache)
return True
return False
def changed(self, path_info, checksum_info):
if not self.exists(path_info):
return True