mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-02-12 13:17:18 +02:00
Avoid creating whiteout for duplicate store paths.
This commit is contained in:
parent
cc6f8aa91a
commit
11c493f8fa
3 changed files with 23 additions and 2 deletions
|
@ -183,11 +183,27 @@ void LocalOverlayStore::deleteGCPath(const Path & path, uint64_t & bytesFreed)
|
||||||
warn("local-overlay: unexpected gc path '%s' ", path);
|
warn("local-overlay: unexpected gc path '%s' ", path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pathExists(toUpperPath({path.substr(mergedDir.length())}))) {
|
|
||||||
LocalStore::deleteGCPath(path, bytesFreed);
|
StorePath storePath = {path.substr(mergedDir.length())};
|
||||||
|
auto upperPath = toUpperPath(storePath);
|
||||||
|
|
||||||
|
if (pathExists(upperPath)) {
|
||||||
|
std::cerr << " upper exists" << std::endl;
|
||||||
|
if (lowerStore->isValidPath(storePath)) {
|
||||||
|
std::cerr << " lower exists" << std::endl;
|
||||||
|
// Path also exists in lower store.
|
||||||
|
// We must delete via upper layer to avoid creating a whiteout.
|
||||||
|
deletePath(upperPath, bytesFreed);
|
||||||
|
_remountRequired = true;
|
||||||
|
} else {
|
||||||
|
// Path does not exist in lower store.
|
||||||
|
// So we can delete via overlayfs and not need to remount.
|
||||||
|
LocalStore::deleteGCPath(path, bytesFreed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LocalOverlayStore::optimiseStore()
|
void LocalOverlayStore::optimiseStore()
|
||||||
{
|
{
|
||||||
Activity act(*logger, actOptimiseStore);
|
Activity act(*logger, actOptimiseStore);
|
||||||
|
@ -209,6 +225,7 @@ void LocalOverlayStore::optimiseStore()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path LocalOverlayStore::toRealPathForHardLink(const StorePath & path)
|
Path LocalOverlayStore::toRealPathForHardLink(const StorePath & path)
|
||||||
{
|
{
|
||||||
return lowerStore->isValidPath(path)
|
return lowerStore->isValidPath(path)
|
||||||
|
@ -216,6 +233,7 @@ Path LocalOverlayStore::toRealPathForHardLink(const StorePath & path)
|
||||||
: Store::toRealPath(path);
|
: Store::toRealPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static RegisterStoreImplementation<LocalOverlayStore, LocalOverlayStoreConfig> regLocalOverlayStore;
|
static RegisterStoreImplementation<LocalOverlayStore, LocalOverlayStoreConfig> regLocalOverlayStore;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,6 +123,8 @@ private:
|
||||||
void optimiseStore() override;
|
void optimiseStore() override;
|
||||||
|
|
||||||
Path toRealPathForHardLink(const StorePath & storePath) override;
|
Path toRealPathForHardLink(const StorePath & storePath) override;
|
||||||
|
|
||||||
|
bool _remountRequired = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ lowerInode=$(stat -c %i "$storeA/$lowerPath")
|
||||||
|
|
||||||
# Now delete file via the overlay store
|
# Now delete file via the overlay store
|
||||||
nix-store --store "$storeB" --delete "$upperPath"
|
nix-store --store "$storeB" --delete "$upperPath"
|
||||||
|
remountOverlayfs
|
||||||
|
|
||||||
# Check there is no longer a file in upper layer
|
# Check there is no longer a file in upper layer
|
||||||
expect 1 stat "$storeBTop/${upperPath##/nix/store/}"
|
expect 1 stat "$storeBTop/${upperPath##/nix/store/}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue