10 my $root = shift @ARGV;
14 if (my $file = IO::File->new("${root}/tmp/manifest.json", "r"))
16 $manifest = decode_json(join("\n", $file->getlines));
22 die "Can't open ${root}/tmp/manifest.json: $!";
25 expire_assets($manifest, "${root}/public/assets", "");
32 my $assetroot = shift;
35 if (my $dir = IO::Dir->new("${assetroot}/${prefix}"))
37 $prefix = "${prefix}/" unless $prefix eq "";
39 while (my $name = $dir->read)
41 next if $name eq "." || $name eq "..";
43 my $path = $name = "${prefix}${name}";
47 if (-d "${assetroot}/${path}")
49 expire_assets($manifest, $assetroot, $path);
51 elsif (exists($manifest->{files}->{$name}))
53 # Still a live asset (with checksum)
55 elsif (exists($manifest->{assets}->{$name}))
57 # Still a live asset (without checksum)
59 elsif (-A "${assetroot}/${path}" > 28)
61 unlink("${assetroot}/${path}") || die "Can't remove ${assetroot}/${path}: $!";
69 die "Can't read ${assetroot}/${prefix}: $!";