mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
fs: rename getsize to size
This commit is contained in:
committed by
Saugat Pachhai
parent
fecc81e951
commit
8ead29805f
+1
-1
@@ -33,7 +33,7 @@ def _upload_file(from_fs_path, fs, odb, upload_odb):
|
||||
tmp_info = fs_path.join(upload_odb.fs_path, tmp_fname())
|
||||
with fs.open(from_fs_path, mode="rb", chunk_size=fs.CHUNK_SIZE) as stream:
|
||||
stream = HashedStreamReader(stream)
|
||||
size = fs.getsize(from_fs_path)
|
||||
size = fs.size(from_fs_path)
|
||||
upload_odb.fs.upload(
|
||||
stream, tmp_info, desc=fs_path.name(from_fs_path), total=size
|
||||
)
|
||||
|
||||
+1
-1
@@ -226,7 +226,7 @@ class Tree(HashFile):
|
||||
def du(odb, tree):
|
||||
try:
|
||||
return sum(
|
||||
odb.fs.getsize(odb.hash_to_path(oid.value)) for _, _, oid in tree
|
||||
odb.fs.size(odb.hash_to_path(oid.value)) for _, _, oid in tree
|
||||
)
|
||||
except FileNotFoundError:
|
||||
return None
|
||||
|
||||
+2
-2
@@ -305,8 +305,8 @@ class FileSystem:
|
||||
):
|
||||
return self.fs.walk(path, topdown=topdown, **kwargs)
|
||||
|
||||
def getsize(self, path: AnyFSPath) -> Optional[int]:
|
||||
return self.info(path).get("size")
|
||||
def size(self, path: AnyFSPath) -> Optional[int]:
|
||||
return self.fs.size(path)
|
||||
|
||||
# pylint: enable=unused-argument
|
||||
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ def _copy(
|
||||
return from_fs.download_file(from_path, to_path)
|
||||
|
||||
with from_fs.open(from_path, mode="rb") as fobj:
|
||||
size = from_fs.getsize(from_path)
|
||||
size = from_fs.size(from_path)
|
||||
return to_fs.upload(fobj, to_path, total=size)
|
||||
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ def file_md5(fname, fs):
|
||||
|
||||
hash_md5 = hashlib.md5()
|
||||
binary = not istextfile(fname, fs=fs)
|
||||
size = fs.getsize(fname) or 0
|
||||
size = fs.size(fname) or 0
|
||||
no_progress_bar = True
|
||||
if size >= LARGE_FILE_SIZE:
|
||||
no_progress_bar = False
|
||||
|
||||
@@ -206,8 +206,8 @@ def test_fs_getsize(dvc, cloud):
|
||||
cls, config, path = get_cloud_fs(dvc, **cloud.config)
|
||||
fs = cls(**config)
|
||||
|
||||
assert fs.getsize(fs.path.join(path, "baz")) == 7
|
||||
assert fs.getsize(fs.path.join(path, "data", "foo")) == 3
|
||||
assert fs.size(fs.path.join(path, "baz")) == 7
|
||||
assert fs.size(fs.path.join(path, "data", "foo")) == 3
|
||||
|
||||
|
||||
def test_fs_upload_fobj(dvc, tmp_dir, cloud):
|
||||
@@ -265,7 +265,7 @@ def test_download_callback(tmp_dir, dvc, cloud, local_cloud):
|
||||
|
||||
(tmp_dir / "to_upload").write_text("foo")
|
||||
fs.upload((tmp_dir / "to_upload").fs_path, (cloud / "foo").fs_path)
|
||||
expected_size = fs.getsize((cloud / "foo").fs_path)
|
||||
expected_size = fs.size((cloud / "foo").fs_path)
|
||||
|
||||
callback = fsspec.Callback()
|
||||
fs.download_file(
|
||||
|
||||
Reference in New Issue
Block a user