Skip to content

Commit 4982159

Browse files
committed
add warning on partial move
1 parent c367a41 commit 4982159

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cloudpathlib/http/httpclient.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from typing import Iterable, Optional, Tuple, Union, Callable
1010
import shutil
1111
import mimetypes
12+
import warnings
1213

1314
from cloudpathlib.client import Client, register_client_class
1415
from cloudpathlib.enums import FileCacheMode
@@ -101,7 +102,14 @@ def _move_file(self, src: HttpPath, dst: HttpPath, remove_src: bool = True) -> H
101102
# .fspath will download the file so the local version can be uploaded
102103
self._upload_file(src.fspath, dst)
103104
if remove_src:
104-
self._remove(src)
105+
try:
106+
self._remove(src)
107+
except Exception as e:
108+
warnings.warn(
109+
f"File was successfully uploaded to {dst} but failed to remove original {src}: {e}",
110+
UserWarning,
111+
)
112+
raise
105113
return dst
106114

107115
def _remove(self, cloud_path: HttpPath, missing_ok: bool = True) -> None:

0 commit comments

Comments
 (0)