From bb8cc22560c5efcc71362c76fe91d8604b5e4f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Saugat=20Pachhai=20=28=E0=A4=B8=E0=A5=8C=E0=A4=97=E0=A4=BE?= =?UTF-8?q?=E0=A4=A4=29?= Date: Wed, 25 Dec 2024 17:27:59 +0545 Subject: [PATCH] destroy: use dvc_object's remove() instead of shutil.rmtree `dvc_objects.fs.utils.remove()` works for readonly files too. --- src/datachain/cache.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/datachain/cache.py b/src/datachain/cache.py index ba6e78bc0..750851eb4 100644 --- a/src/datachain/cache.py +++ b/src/datachain/cache.py @@ -1,5 +1,4 @@ import os -import shutil from collections.abc import Iterator from contextlib import contextmanager from tempfile import mkdtemp @@ -7,6 +6,7 @@ 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 @@ -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) def get_total_size(self) -> int: total = 0