Verify memoized files can be reloaded before using them

Fixes #233.
This commit is contained in:
Gavin Lambert
2015-07-17 13:36:00 +12:00
parent 658589fec1
commit 1673688cde

View File

@@ -1585,6 +1585,11 @@ sub tie_for_persistent_memoization {
if ($memo_backend > 0) {
tie %$hash => 'Git::SVN::Memoize::YAML', "$path.yaml";
} else {
# first verify that any existing file can actually be loaded
# (it may have been saved by an incompatible version)
if (-e "$path.db") {
unlink "$path.db" unless eval { retrieve("$path.db"); 1 };
}
tie %$hash => 'Memoize::Storable', "$path.db", 'nstore';
}
}