Skip to content

Commit

Permalink
destroy: use dvc_object's remove() instead of shutil.rmtree
Browse files Browse the repository at this point in the history
`dvc_objects.fs.utils.remove()` works for readonly files too.
  • Loading branch information
skshetry committed Dec 25, 2024
1 parent 91f30b6 commit bb8cc22
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/datachain/cache.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import os
import shutil
from collections.abc import Iterator
from contextlib import contextmanager
from tempfile import mkdtemp
from typing import TYPE_CHECKING, Optional

from dvc_data.hashfile.db.local import LocalHashFileDB
from dvc_objects.fs.local import LocalFileSystem
from dvc_objects.fs.utils import remove
from fsspec.callbacks import Callback, TqdmCallback

from .progress import Tqdm
Expand Down Expand Up @@ -117,7 +117,7 @@ def clear(self):

def destroy(self):
# `clear` leaves the prefix directory structure intact.
shutil.rmtree(self.cache_dir)
remove(self.cache_dir)

Check warning on line 120 in src/datachain/cache.py

View check run for this annotation

Codecov / codecov/patch

src/datachain/cache.py#L120

Added line #L120 was not covered by tests

def get_total_size(self) -> int:
total = 0
Expand Down

0 comments on commit bb8cc22

Please sign in to comment.