make dedup pass test and refactore JSON store
[cloudstore.git] / lib / CloudStore / dedup.pm
index 59fe133..fafd5e8 100644 (file)
@@ -3,6 +3,9 @@ use warnings;
 use strict;
 use autodie;
 
+use CloudStore::JSON;
+use Data::Dump qw(dump);
+
 sub path_md5 {
        my ( $path, $md5 ) = @_;
 
@@ -23,9 +26,12 @@ sub path_md5 {
 sub path_remove {
        my ( $path ) = @_;
 
-       my ( undef, undef, undef, $nlink ) = stat $path;
+       my $deleted = CloudStore::JSON::file_data( $path );
+
+       my ( undef, undef, undef, $nlink ) = stat "md5/$deleted->{md5}";
+
+       warn "path_remove $path $nlink ",dump $deleted;
 
-       warn "nlink $path $nlink";
 }
 
 my $empty_md5 = " " x 32;