Skip to content

Commit b9f9854

Browse files
committed
only add result if upload successful
1 parent 6596cbc commit b9f9854

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

nextcloudclient/upload.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def upload_to_nextcloud(source_paths: list[str], remote_name: str, remote_path:
3535
basename = os.path.basename(abs_path)
3636
files = get_all_files(abs_path)
3737

38+
tmp_results = []
39+
3840
for file in files:
3941
checksum,size = compute_sha256_and_length(file)
4042

@@ -47,7 +49,7 @@ def upload_to_nextcloud(source_paths: list[str], remote_name: str, remote_path:
4749
url = posixpath.join(webdav_url,remote_webdav_path)
4850

4951
filename = file.split("/")[-1]
50-
result.append((filename, checksum, size, url))
52+
tmp_results.append((filename, checksum, size, url))
5153

5254
if os.path.isdir(path):
5355
destination = f"{remote_name}:{remote_path}/{basename}"
@@ -59,6 +61,7 @@ def upload_to_nextcloud(source_paths: list[str], remote_name: str, remote_path:
5961
print(f"Upload: {path}{destination}")
6062
try:
6163
subprocess.run(command, check=True)
64+
result.append(tmp_results)
6265
print("✅ Uploaded successfully.\n")
6366
except subprocess.CalledProcessError as e:
6467
print(f"❌ Error uploading {path}: {e}\n")

0 commit comments

Comments
 (0)