Fixes channel going back in time due to incomplete change.

The change in d3d33d5b25 changed how the
locally saved channel information was saved on the local machine.

 * d3d33d5b25 (diff-682bf482f6dd273f1c3c49afd99b4660R192)

The changeset did *not* change the guard clause, which now made it act
like this:

 1. Try readlink on the file
 2. (bail as it's undefined)

The new behaviour is as more or less expected:

 1. Reads the file if available
 2. Split the URL components
 3. Keep the last bit

This can give us an empty string, which will compare to `-1` thus
fulfilling the need.
This commit is contained in:
Samuel Dionne-Riel 2018-08-25 23:18:47 -04:00
parent e9587f9388
commit d313d2bd51

View file

@ -72,13 +72,11 @@ my $rev = $evalInfo->{jobsetevalinputs}->{nixpkgs}->{revision} or die;
print STDERR "release is $releaseName (build $releaseId), eval is $evalId, prefix is $releasePrefix, Git commit is $rev\n";
# Guard against the channel going back in time.
my $curReleaseDir = readlink "$channelsDir/$channelName";
if (defined $curReleaseDir) {
my $curRelease = basename($curReleaseDir);
my $d = `NIX_PATH= nix-instantiate --eval -E "builtins.compareVersions (builtins.parseDrvName \\"$curRelease\\").version (builtins.parseDrvName \\"$releaseName\\").version"`;
chomp $d;
die "channel would go back in time from $curRelease to $releaseName, bailing out\n" if $d == 1;
}
my @releaseUrl = split(/\//, read_file("$channelsDir/$channelName", err_mode => 'quiet') // "");
my $curRelease = pop @releaseUrl;
my $d = `NIX_PATH= nix-instantiate --eval -E "builtins.compareVersions (builtins.parseDrvName \\"$curRelease\\").version (builtins.parseDrvName \\"$releaseName\\").version"`;
chomp $d;
die "channel would go back in time from $curRelease to $releaseName, bailing out\n" if $d == 1;
if ($bucket->head_key("$releasePrefix")) {
print STDERR "release already exists\n";