Arkiwi FTP
This commit is contained in:
parent
5942979b91
commit
9df8dd1910
1 changed files with 18 additions and 2 deletions
|
@ -78,6 +78,9 @@ class ArkiwiBackend(RcloneBackend):
|
|||
super().__init__(remote_name)
|
||||
self.prefix: bytes = prefix.strip("/").encode("utf8")
|
||||
|
||||
def ftp_path(self, path: bytes) -> bytes:
|
||||
return b"ftp://upload.arkiwi.org/%s/" % (destination_path.strip(b"/"),))
|
||||
|
||||
def actual_path(self, path: bytes) -> bytes:
|
||||
return self.prefix + b"/" + path.lstrip(b"/")
|
||||
|
||||
|
@ -90,14 +93,27 @@ class ArkiwiBackend(RcloneBackend):
|
|||
)
|
||||
return f"https://www.arkiwi.org/path64/{path}/redirect"
|
||||
|
||||
#2024-11-05: cambio da rclone a curl per girare intorno ai bug di webdav. Poi bisogna togliere l'intero metodo, così torniamo a quello di RcloneBackend
|
||||
def exists(self, destination_path: bytes):
|
||||
return False
|
||||
cmd = ["curl", "--netrc", "--head", "--silent", self.ftp_path(destination_path)]
|
||||
try:
|
||||
output = subprocess.check_output(cmd)
|
||||
except subprocess.CalledProcessError as exc:
|
||||
if exc.returncode == 3:
|
||||
return False
|
||||
raise
|
||||
|
||||
return bool(output)
|
||||
|
||||
def copy(self, filename: Path, destination_path: bytes) -> str:
|
||||
"""
|
||||
returns the URL
|
||||
"""
|
||||
super().copy(filename, self.actual_path(destination_path))
|
||||
# 2024-11-05: siccome webdav è rotto e invece FTP funziona, sostituisco la copia webdav (rclone) con una fatta con curl
|
||||
# super().copy(filename, self.actual_path(destination_path))
|
||||
cmd = ["curl", "--netrc", "--upload-file", str(filename), self.ftp_path(destination_path)]
|
||||
subprocess.run(cmd, check=True)
|
||||
|
||||
url = self.path_to_url(destination_path)
|
||||
response = requests.head(url, allow_redirects=True)
|
||||
response.raise_for_status()
|
||||
|
|
Loading…
Reference in a new issue