mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
repo: use local root when determining state/index db dirname
This commit is contained in:
committed by
Peter Rowlands (변기호)
parent
50fd8ca15d
commit
96ac321dd5
+12
-4
@@ -126,6 +126,8 @@ class Repo:
|
||||
return root_dir, dvc_dir
|
||||
|
||||
def _get_database_dir(self, db_name: str) -> Optional[str]:
|
||||
from dvc.fs import localfs
|
||||
|
||||
# NOTE: by default, store SQLite-based remote indexes and state's
|
||||
# `links` and `md5s` caches in the repository itself to avoid any
|
||||
# possible state corruption in 'shared cache dir' scenario, but allow
|
||||
@@ -138,15 +140,21 @@ class Repo:
|
||||
|
||||
import hashlib
|
||||
|
||||
root_dir_hash = hashlib.sha224(self.root_dir.encode("utf-8")).hexdigest()
|
||||
if self.local_dvc_dir:
|
||||
fs: "FileSystem" = localfs
|
||||
local_root = fs.path.parent(self.local_dvc_dir)
|
||||
else:
|
||||
fs = self.fs
|
||||
local_root = self.root_dir
|
||||
root_dir_hash = hashlib.sha224(local_root.encode("utf-8")).hexdigest()
|
||||
|
||||
db_dir = self.fs.path.join(
|
||||
db_dir = fs.path.join(
|
||||
base_db_dir,
|
||||
self.DVC_DIR,
|
||||
f"{self.fs.path.name(self.root_dir)}-{root_dir_hash[0:7]}",
|
||||
f"{fs.path.name(local_root)}-{root_dir_hash[0:7]}",
|
||||
)
|
||||
|
||||
self.fs.makedirs(db_dir, exist_ok=True)
|
||||
fs.makedirs(db_dir, exist_ok=True)
|
||||
return db_dir
|
||||
|
||||
def __init__( # noqa: PLR0915
|
||||
|
||||
@@ -66,6 +66,8 @@ def test_remote_index_dir_config(make_tmp_dir, dvc):
|
||||
conf["remote"]["s3"] = {"url": "s3://bucket/name"}
|
||||
|
||||
dvc.root_dir = "/usr/local/test_repo"
|
||||
dvc.dvc_dir = "/usr/local/test_repo/.dvc"
|
||||
dvc.__dict__.pop("local_dvc_dir")
|
||||
|
||||
assert os.path.dirname(
|
||||
get_index(dvc.cloud.get_remote_odb(name="s3")).index_dir
|
||||
|
||||
Reference in New Issue
Block a user