Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ classifiers = [
requires-python = ">=3.8"
dynamic = ["version"]
dependencies = [
"shortuuid>=0.5.0",
"funcy>=1.14",
"fsspec>=2022.10.0",
]
Expand Down
11 changes: 4 additions & 7 deletions src/dvc_objects/fs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import threading
from concurrent import futures
from contextlib import contextmanager, suppress
from secrets import token_urlsafe
from typing import TYPE_CHECKING, Any, Collection, Dict, Iterator, Optional, Set, Union

from dvc_objects.executors import ThreadPoolExecutor
Expand Down Expand Up @@ -60,10 +61,8 @@ def move(src: "AnyFSPath", dst: "AnyFSPath") -> None:
case src and dst are on different filesystems and actual physical copying
of data is happening.
"""
from shortuuid import uuid

dst = os.path.abspath(dst)
tmp = f"{dst}.{uuid()}"
tmp = tmp_fname(dst)

if os.path.islink(src):
shutil.copy(src, tmp)
Expand Down Expand Up @@ -173,11 +172,9 @@ def copyfile(
shutil.copyfileobj(fsrc, wrapped, length=LOCAL_CHUNK_SIZE)


def tmp_fname(fname: "AnyFSPath" = "") -> "AnyFSPath":
def tmp_fname(prefix: str = "") -> str:
"""Temporary name for a partial download"""
from shortuuid import uuid

return os.fspath(fname) + "." + uuid() + ".tmp"
return f"{prefix}.{token_urlsafe(16)}.tmp"


@contextmanager
Expand Down
2 changes: 1 addition & 1 deletion tests/fs/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_tmp_fname():
file = os.path.join("path", "to", "file")

def pattern(path):
return r"^" + re.escape(path) + r"\.[a-z0-9]{22}\.tmp$"
return r"^" + re.escape(path) + r"\.[a-z0-9_-]{22}\.tmp$"

assert re.search(pattern(file), utils.tmp_fname(file), re.IGNORECASE)
assert re.search(
Expand Down