mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 23:11:44 +01:00
remote: RFC: unify changed_cache
Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user