[Dbix-class] dirty-flag on inflated columns

Marc Mims marc at questright.com
Tue May 12 20:51:00 GMT 2009


* Matt S Trout <dbix-class at trout.me.uk> [090512 11:34]:
> On Mon, May 11, 2009 at 12:14:07PM -0700, Marc Mims wrote:
> > * Matt S Trout <dbix-class at trout.me.uk> [090511 10:29]:
> > > Thoughts on whether make_column_dirty should clear the deflated value if an
> > > inflated one is present, guys?
> > 
> > That would break DBIx::Class::InflateColumn::FS, causing it to leave an
> > orphaned file in the file system.
> 
> Why?

FS uses the deflated value to determine whether it needs to overwrite an
existing file or create a new file.  If the deflated value is cleared by
make_column_dirty, FS will always make a copy, potentially orphaning a
file in fs_column_path.

The deflated value is a unique filename in a path specified by
fs_column_path.  On deflation:

   - If the inflated value (a Path::Class::File object) and the deflated
     value represent the SAME file in fs_column_path, deflation is a
     no-op.

   - If there is no deflated value, a new, unique file is created in
     fs_column_path.

   - Otherwise, the contents of the file specified by the deflated value
     is overwritten by the contents of the file represented by the
     inflated value.

Then FS clears the inflated value (the Path::Class::File object, NOT the
source file itself).  That forces re-inflation on the next access so
that the inflated Path::Class::File points to the unique file in
fs_column_path, not the source file it was copied from.

If make_column_dirty clears the deflated value, all three cases above
will be treated like the second case.  In the first case, X will be
copied to a new, unique file, leaving X orphaned.

If make_column_dirty clears the deflated value, I will have some work to
do on FS to accommodate the change.

	-Marc



More information about the DBIx-Class mailing list