Skip to content

Commit

Permalink
Do not hardlink symlink assets
Browse files Browse the repository at this point in the history
Issue: https://progress.opensuse.org/issues/129340

Hardlinking a symlink will only work if the link is absolute, and
we would have to check that recursively if the symlink target
itself is a symlink, so just fall back to symlink then.
  • Loading branch information
perlpunk committed Jun 23, 2023
1 parent 8d9fc92 commit 5867bcb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/OpenQA/Worker/Engines/isotovideo.pm
Expand Up @@ -176,10 +176,16 @@ sub _link_asset ($asset, $pooldir) {
# Try to use hardlinks first and only fall back to symlinks when that fails,
# to ensure that assets cannot be purged early from the pool even if the
# cache service runs out of space
eval { link($asset, $target) or die qq{Cannot create link from "$asset" to "$target": $!} };
if (my $err = $@) {
# If the given asset is a symlink itself, to not hardlink a symlink
my $linked = 0;
unless (-l $asset) {
$linked = eval { link($asset, $target) or die qq{Cannot create link from "$asset" to "$target": $!} };
if (my $err = $@) {
log_debug(qq{Symlinking asset because hardlink failed: $err});

Check warning on line 184 in lib/OpenQA/Worker/Engines/isotovideo.pm

View check run for this annotation

Codecov / codecov/patch

lib/OpenQA/Worker/Engines/isotovideo.pm#L184

Added line #L184 was not covered by tests
}
}
unless ($linked) {
symlink($asset, $target) or die qq{Cannot create symlink from "$asset" to "$target": $!};
log_debug(qq{Symlinked asset because hardlink failed: $err});
}
log_debug(qq{Linked asset "$asset" to "$target"});

Expand Down

0 comments on commit 5867bcb

Please sign in to comment.