Skip Menu |

This queue is for tickets about the CHI CPAN distribution.

Report information
The Basics
Id: 78590
Status: open
Priority: 0/
Queue: CHI

People
Owner: Nobody in particular
Requestors: BBYRD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: CHI::Driver::File should consult POSIX's PATH_MAX for max_key_length
Instead of requiring the user to eventually figure it out, the File driver should use a sane default for max_key_length based on POSIX's PATH_MAX, the root_dir, and expected length of the namespace, directories, etc. Windows only has a PATH_MAX of 260, so storage of any large keys will typically not work. Since there is no error message by default, it will be silently ignored. Here's a formula to use for setting a max_key_length: PATH_MAX - length( $root_dir->subdir($namespace, 0, 0) ) - 4 - 8 The 4 is the '.dat' extension, and the 8 is an extra margin of error.
Specifically, this works: min( POSIX::PATH_MAX - length( $root_dir->subdir($namespace, 0, 0)->absolute->stringify ) - 4 - 8, 248)
CHI::Driver::File currently defaults max_key_length to 248, and should automatically digest keys that grow larger than that (after characters are escaped for file system safety). You say that larger keys typically "will not work" on Windows - have you actually observed that? If so it means that something about the above is not working.
On Sat Aug 25 20:30:27 2012, JSWARTZ wrote: Show quoted text
> CHI::Driver::File currently defaults max_key_length to 248, and should > automatically digest keys that grow larger than that (after characters > are escaped for file system safety). > > You say that larger keys typically "will not work" on Windows - have you > actually observed that? If so it means that something about the above is > not working.
Yes, this came from an example of using Dist::Zilla::Role::MetaCPANInterfacer on my Windows laptop. While the 248 max is larger than 260, it doesn't present a lot of room for the root path; only 12 chars. So, something like "C:\Documents and Settings..." is already going to run past PATH_MAX. This would be present in my module here: CHI->new( namespace => 'MetaCPAN', driver => 'File', expires_in => '1d', root_dir => Path::Class::dir( File::HomeDir->my_home )->subdir('.dzil', '.webcache')->stringify, ) Once you go past PATH_MAX, you start running into "File not found" errors for the cache entries.
Subject: Re: [rt.cpan.org #78590] CHI::Driver::File should consult POSIX's PATH_MAX for max_key_length
Date: Tue, 11 Sep 2012 15:26:38 -0400
To: bug-CHI [...] rt.cpan.org
From: Jonathan Swartz <swartz [...] pobox.com>
Oh, max_key_length will only affect the filename that gets created. You're talking about the maximum path including all the directories plus the file? On Sep 11, 2012, at 3:23 PM, Brendan Byrd via RT wrote: Show quoted text
> Queue: CHI > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=78590 > > > On Sat Aug 25 20:30:27 2012, JSWARTZ wrote:
>> CHI::Driver::File currently defaults max_key_length to 248, and should >> automatically digest keys that grow larger than that (after characters >> are escaped for file system safety). >> >> You say that larger keys typically "will not work" on Windows - have you >> actually observed that? If so it means that something about the above is >> not working.
> > Yes, this came from an example of using > Dist::Zilla::Role::MetaCPANInterfacer on my Windows laptop. While the > 248 max is larger than 260, it doesn't present a lot of room for the > root path; only 12 chars. So, something like "C:\Documents and > Settings..." is already going to run past PATH_MAX. > > This would be present in my module here: > > CHI->new( > namespace => 'MetaCPAN', > driver => 'File', > expires_in => '1d', > root_dir => Path::Class::dir( File::HomeDir->my_home > )->subdir('.dzil', '.webcache')->stringify, > ) > > Once you go past PATH_MAX, you start running into "File not found" > errors for the cache entries.
On Tue Sep 11 15:26:51 2012, swartz@pobox.com wrote: Show quoted text
> Oh, max_key_length will only affect the filename that gets created. > You're talking about the maximum path including all the directories > plus the file?
Correct. In a grand majority of cases, it won't work on Win32 systems, because of that short amount of space in-between.