Skip to content

Commit

Permalink
More Error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgross committed Feb 11, 2024
1 parent 54ae08e commit 75ab098
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/pcloud/pcloudfs.py
Expand Up @@ -205,6 +205,8 @@ def getinfo(self, path, namespaces=None):
namespaces = namespaces or ()
_path = self.validatepath(path)
resp = self.pcloud.stat(path=_path)
if resp.get("result") != 0:
api.log.error(f"Upload Error for file {_path}: {resp}")
metadata = resp.get("metadata", None)
if metadata is None:
raise errors.ResourceNotFound(path=path)
Expand Down Expand Up @@ -300,7 +302,7 @@ def on_close(pcloudfile):
filename=pcloudfile.filename,
)
if resp.get("result") != 0:
print(f"Upload Error: {resp}")
api.log.error(f"Upload Error for file {_path}: {resp}")
return
pcloudfile.raw.close()

Expand Down Expand Up @@ -374,7 +376,9 @@ def removedir(self, path):
if not self.isempty(_path):
raise errors.DirectoryNotEmpty(_path)
with self._lock:
self.pcloud.deletefolder(path=_path)
resp = self.pcloud.deletefolder(path=_path)
if resp["result"] != 0:
api.log.error(f"Removing of folder {_path} failed {resp}")

def removetree(self, dir_path):
_path = self.validatepath(dir_path)
Expand All @@ -383,8 +387,9 @@ def removetree(self, dir_path):
if self.getinfo(_path).is_dir == False:
raise errors.DirectoryExpected(_path)
with self._lock:
self.pcloud.deletefolderrecursive(path=_path)

resp = self.pcloud.deletefolderrecursive(path=_path)
if resp["result"] != 0:
api.log.error(f"Recurrsive removing of folder {_path} failed {resp}")

class PCloudOpener(Opener):
protocols = ["pcloud"]
Expand Down

0 comments on commit 75ab098

Please sign in to comment.