Storage backends: added exists() method
This method returns whether the file exists on the backend.
This commit is contained in:
@@ -149,5 +149,9 @@ class Blob(metaclass=abc.ABCMeta):
|
||||
Only performs an actual action on backends that support temporary links.
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def exists(self) -> bool:
|
||||
"""Returns True iff the file exists on the storage backend."""
|
||||
|
||||
|
||||
Bl = typing.TypeVar('Bl', bound=Blob)
|
||||
|
@@ -180,6 +180,11 @@ class GoogleCloudStorageBlob(Blob):
|
||||
def make_public(self):
|
||||
self.gblob.make_public()
|
||||
|
||||
def exists(self) -> bool:
|
||||
# Reload to get the actual file properties from Google.
|
||||
self.gblob.reload()
|
||||
return self.gblob.exists()
|
||||
|
||||
|
||||
def update_file_name(node):
|
||||
"""Assign to the CGS blob the same name of the asset node. This way when
|
||||
|
@@ -100,3 +100,6 @@ class LocalBlob(Blob):
|
||||
def make_public(self):
|
||||
# No-op on this storage backend.
|
||||
pass
|
||||
|
||||
def exists(self) -> bool:
|
||||
return self.abspath().exists()
|
||||
|
Reference in New Issue
Block a user