link support stable

This commit is contained in:
IlyaShurupov 2024-03-28 17:28:49 +03:00
parent 2f83cf5f05
commit b093ba7ad4
3 changed files with 12 additions and 1 deletions

View file

@ -127,6 +127,11 @@ bool Directory::detachNode(const Key& key) {
return false;
}
if (removeNode->key.incomingLinksHard || removeNode->key.incomingLinksDynamic) {
gError = "Cannot modify node with incoming hard links";
return false;
}
removeNode->mParent = nullptr;
mMembers.remove(DirectoryKey(key));

View file

@ -170,7 +170,10 @@ bool FileSystem::moveNode(const Path &source, const Path &target) {
return false;
}
assert(sourceParentDirectory->detachNode(key));
if (!sourceParentDirectory->detachNode(key)) {
return false;
}
assert(targetDirectory->attachNode(key, sourceNode));
return true;

View file

@ -34,6 +34,9 @@ int main() {
interpreter.interpret("copy a /");
interpreter.interpret("mdl a/b/c /a-copy/k");
interpreter.interpret("move a/b/c /a-copy");
interpreter.interpret("del /a-copy/k/c");
return UnitTest::RunAllTests();