Skip to content

Commit

Permalink
Fetch: Remove suffix from downloaded profile
Browse files Browse the repository at this point in the history
Provide a symlink with the old name for backwards compatibility.
  • Loading branch information
jrha committed Aug 24, 2023
1 parent 1676419 commit a83d825
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/main/perl/Fetch/ProfileCache.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use EDG::WP4::CCM::CacheManager::DB;

use CAF::FileWriter;
use CAF::FileReader;
use CAF::Path;
use CAF::Lock qw(FORCE_IF_STALE);
use Digest::MD5 qw(md5_hex);
use Readonly;
Expand Down Expand Up @@ -238,7 +239,7 @@ sub previous
$ret{url} = CAF::FileReader->new("$dir/profile.url", log => $self);
chomp($ret{url}); # this actually works

$ret{profile} = CAF::FileReader->new("$dir/profile.xml", log => $self);
$ret{profile} = CAF::FileReader->new("$dir/profile", log => $self);

return %ret;
}
Expand All @@ -264,11 +265,14 @@ sub current
url => CAF::FileWriter->new("$dir/profile.url", %{$self->{permission}->{file}}),
cid => CAF::FileWriter->new("$self->{CACHE_ROOT}/$CURRENT_CID_FN",
%{$self->{permission}->{file}}),
profile => CAF::FileWriter->new("$dir/profile.xml", %{$self->{permission}->{file}}),
profile => CAF::FileWriter->new("$dir/profile", %{$self->{permission}->{file}}),
eiddata => "$dir/$EID2DATA",
eidpath => "$dir/$PATH2EID"
);

my $cafpath = CAF::Path::mkcafpath(log => $self);
$cafpath->symlink("$dir/profile", "$dir/profile.xml");

# Prepare new profile/CID to become current one
# newline at end is important (see _read_syncfile in CacheManager)
$current{cid}->print("$cid\n");
Expand Down
3 changes: 2 additions & 1 deletion src/test/perl/fetch.t
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ $pf = $f->retrieve($f->{PROFILE_URL}, "target/test/file-output", 0);
isa_ok($pf, "CAF::FileReader");
$pf->cancel();

unlink("target/test/profile");
unlink("target/test/profile.xml");
compile_profile("pan.gz");
$pf = $f->retrieve("$f->{PROFILE_URL}", "target/test-file-output", 0);
Expand Down Expand Up @@ -413,7 +414,7 @@ isa_ok($pf, "CAF::FileReader", "download retruns CAF::FileReader instance");
my %r = $f->previous();
like(*{$r{url}}->{filename}, qr{profile.url$},
'Correct file read for the previous URL');
like(*{$r{profile}}->{filename}, qr{profile.xml$},
like(*{$r{profile}}->{filename}, qr{profile$},
"Correct file read with the previous XML");
ok(exists($r{cid}), "cid created");
foreach my $i (qw(cid url profile)) {
Expand Down

0 comments on commit a83d825

Please sign in to comment.