Subject: | share_file doesn't behave well if given an object (like Path::Class::File...) |
Ran into a strange and difficult-to-find problem today. If
Cache::FastMmap is given an object for it's share_file parameter, say
something like this:
my $cache = Cache::FastMmap->new(
share_file => Path::Class::File->new( 'cache.mmap' ),
);
It doesn't complain about it, instead it just creates an
inexplicably-named file in the current directory (in my case part of the
problem was that the file getting created was always named the same as
if I had done share_file => "\cC").
Cache::FastMmap should probably either croak if given an object, or try
and stringify it and use that. If stringified, even if the object
didn't stringify to a filename, it might at least end up being something
useful instead of some of the bizarre filenames it gets now which
consist mostly of non-printable characters. Attached is a trivial patch
which stringifies the value passed to share_file.
Subject: | Cache-FastMmap.patch |
--- Cache/FastMmap.pm 2007-10-21 23:14:16.000000000 -0400
+++ Cache/FastMmap.pm 2008-01-11 11:07:26.000000000 -0500
@@ -467,8 +467,8 @@
$share_file = ($^O eq "MSWin32" ? "c:\\sharefile" : "/tmp/sharefile");
$share_file .= "-" . $$ . "-" . time;
}
- $Self->{share_file} = $share_file;
-
+ $Self->{share_file} = "$share_file"; # stringify in case it's an object,
+ # ala Path::Class
my $init_file = $Args{init_file} || 0;
my $test_file = $Args{test_file} || 0;