--- fuse-comp.pl 2007/07/09 10:35:02 12 +++ fuse-comp.pl 2007/07/09 11:12:48 13 @@ -103,13 +103,13 @@ sub file_copy { my ( $s_opt, $s_path, $d_opt, $d_path ) = @_; - warn "## file_copy( $s_opt $s_path $d_opt $d_path )\n"; + warn "## file_copy( $s_opt $s_path [",-s $s_path,"] $d_opt $d_path [",-e $d_path ? -s $d_path : 'new',"])\n"; open(my $s, $s_opt, $s_path ) || confess "can't open $s_path: $!\npending = ", dump( $pending ); open(my $d, $d_opt, $d_path ) || confess "can't open $d_path: $!"; my $buff; while( read( $s, $buff, 65535 ) ) { print $d $buff || confess "can't write into $d_path: $!"; - warn ">> ", length($buff), " bytes, offset ", tell($s), " -> ", tell($d), "\n" if $debug; + warn ">> [", length($buff), "] offset ", tell($s), " -> ", tell($d), "\n" if $debug; } close($d) || warn "can't close $d_path: $!"; close($s) || warn "can't close $s_path: $!"; @@ -161,7 +161,7 @@ file_copy( '<:gzip', $path, '>', $tmp ); $path = $tmp; } - warn ">>> open abs path: $path ", -s $path, " bytes\n"; + warn ">>> open abs path: $path [", -s $path, "]\n"; return -$! unless sysopen($fh , $path, $mode); close($fh); @@ -281,7 +281,7 @@ warn "release $file $mode -- uncompressed\n"; file_copy( '<', $path, '>', $dest ) if ( $path ne $dest ); } elsif ( -s $path < $min_compress_size ) { - warn "release $file -- uncompressed, too small ", -s $path, " bytes\n"; + warn "release $file -- uncompressed, too small [", -s $path, "]\n"; file_copy( '<', $path, '>', $dest ) if ( $path ne $dest ); } else { warn "release $file $mode -- compressing\n"; @@ -294,10 +294,12 @@ } } else { warn "release $file, but still used ", $pending->{$file}->{open} , " times, delaying compression\n"; - $pending->{$file}->{open}--; - return 0; } - delete( $pending->{$file} ); + $pending->{$file}->{open}--; + if ( $pending->{$file}->{open} == 0 ) { + warn "## cleanup pending $file [", -s fixup($file), "]\n" if $debug; + delete( $pending->{$file} ); + } return 0; }