mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-09 23:10:24 +01:00
This is an opt-in mode, that will make data in the workspace read-only, thus protecting cache from corruption when hardlinks or symlinks are used. User can use `dvc unprotect file` command, to replace read-only link to cache with an editable copy. We can use this for now to decide if we want to go with a `unified workflow` in the future or if we want to set unprotected `reflink,copy` by default. Fixes #799 Signed-off-by: Ruslan Kuprieiev <[email protected]>
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import os
|
|
import stat
|
|
|
|
from dvc.main import main
|
|
from dvc.project import Project
|
|
|
|
from tests.basic_env import TestDvc
|
|
|
|
|
|
class TestUnprotect(TestDvc):
|
|
def test(self):
|
|
ret = main(['config', 'cache.protected', 'true'])
|
|
self.assertEqual(ret, 0)
|
|
|
|
ret = main(['add', self.FOO])
|
|
self.assertEqual(ret, 0)
|
|
|
|
self.assertNotEqual(os.stat(self.FOO).st_mode & (stat.S_IREAD|
|
|
stat.S_IRGRP|
|
|
stat.S_IROTH), 0)
|
|
self.assertEqual(os.stat(self.FOO).st_mode & (stat.S_IWRITE|
|
|
stat.S_IWGRP|
|
|
stat.S_IWOTH), 0)
|
|
|
|
ret = main(['unprotect', self.FOO])
|
|
self.assertEqual(ret, 0)
|
|
|
|
self.assertNotEqual(os.stat(self.FOO).st_mode & (stat.S_IREAD|
|
|
stat.S_IRGRP|
|
|
stat.S_IROTH|
|
|
stat.S_IWRITE), 0)
|