… | |
… | |
776 | } |
776 | } |
777 | } else { |
777 | } else { |
778 | aio_unlink $filename; |
778 | aio_unlink $filename; |
779 | aio_unlink "$filename.pst"; |
779 | aio_unlink "$filename.pst"; |
780 | } |
780 | } |
|
|
781 | |
|
|
782 | #d##TODO# nuke non .map-files if exist |
|
|
783 | if ($filename =~ s/\.map$//) { |
|
|
784 | aio_unlink $filename; |
|
|
785 | aio_unlink "$filename.pst"; |
|
|
786 | } |
781 | } |
787 | } |
782 | } |
788 | } |
783 | |
789 | |
784 | sub object_freezer_as_string { |
790 | sub object_freezer_as_string { |
785 | my ($rdata, $objs) = @_; |
791 | my ($rdata, $objs) = @_; |
… | |
… | |
791 | |
797 | |
792 | sub object_thawer_load { |
798 | sub object_thawer_load { |
793 | my ($filename) = @_; |
799 | my ($filename) = @_; |
794 | |
800 | |
795 | my ($data, $av); |
801 | my ($data, $av); |
|
|
802 | |
|
|
803 | #d#TODO remove .map if file does not exist |
|
|
804 | aio_stat $filename and $filename =~ s/\.map$//; |
796 | |
805 | |
797 | (aio_load $filename, $data) >= 0 |
806 | (aio_load $filename, $data) >= 0 |
798 | or return; |
807 | or return; |
799 | |
808 | |
800 | unless (aio_stat "$filename.pst") { |
809 | unless (aio_stat "$filename.pst") { |
… | |
… | |
1251 | |
1260 | |
1252 | # the original (read-only) location |
1261 | # the original (read-only) location |
1253 | sub load_path { |
1262 | sub load_path { |
1254 | my ($self) = @_; |
1263 | my ($self) = @_; |
1255 | |
1264 | |
1256 | sprintf "%s/%s/%s", cf::datadir, cf::mapdir, $self->{path} |
1265 | sprintf "%s/%s/%s.map", cf::datadir, cf::mapdir, $self->{path} |
1257 | } |
1266 | } |
1258 | |
1267 | |
1259 | # the temporary/swap location |
1268 | # the temporary/swap location |
1260 | sub save_path { |
1269 | sub save_path { |
1261 | my ($self) = @_; |
1270 | my ($self) = @_; |
1262 | |
1271 | |
1263 | (my $path = $_[0]{path}) =~ s/\//$PATH_SEP/g; |
1272 | (my $path = $_[0]{path}) =~ s/\//$PATH_SEP/g; |
1264 | sprintf "%s/%s/%s", cf::localdir, cf::tmpdir, $path |
1273 | sprintf "%s/%s/%s.map", cf::localdir, cf::tmpdir, $path |
1265 | } |
1274 | } |
1266 | |
1275 | |
1267 | # the unique path, undef == no special unique path |
1276 | # the unique path, undef == no special unique path |
1268 | sub uniq_path { |
1277 | sub uniq_path { |
1269 | my ($self) = @_; |
1278 | my ($self) = @_; |
… | |
… | |
1285 | my ($self) = @_; |
1294 | my ($self) = @_; |
1286 | |
1295 | |
1287 | utf8::encode (my $save = $self->save_path); |
1296 | utf8::encode (my $save = $self->save_path); |
1288 | IO::AIO::aioreq_pri 4; Coro::AIO::aio_unlink $save; |
1297 | IO::AIO::aioreq_pri 4; Coro::AIO::aio_unlink $save; |
1289 | IO::AIO::aioreq_pri 4; Coro::AIO::aio_unlink "$save.pst"; |
1298 | IO::AIO::aioreq_pri 4; Coro::AIO::aio_unlink "$save.pst"; |
|
|
1299 | |
|
|
1300 | #d#TODO remove .map and also nuke |
|
|
1301 | $save =~ s/\.map// or return;#d# |
|
|
1302 | IO::AIO::aioreq_pri 4; Coro::AIO::aio_unlink $save;#d# |
|
|
1303 | IO::AIO::aioreq_pri 4; Coro::AIO::aio_unlink "$save.pst";#d# |
1290 | } |
1304 | } |
1291 | |
1305 | |
1292 | sub load_header_from($) { |
1306 | sub load_header_from($) { |
1293 | my ($self, $path) = @_; |
1307 | my ($self, $path) = @_; |
1294 | |
1308 | |
1295 | utf8::encode $path; |
1309 | utf8::encode $path; |
1296 | aio_open $path, O_RDONLY, 0 |
1310 | #aio_open $path, O_RDONLY, 0 |
1297 | or return; |
1311 | # or return; |
1298 | |
1312 | |
1299 | $self->_load_header ($path) |
1313 | $self->_load_header ($path) |
1300 | or return; |
1314 | or return; |
1301 | |
1315 | |
1302 | $self->{load_path} = $path; |
1316 | $self->{load_path} = $path; |