remove json store left-overs
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 12 Feb 2012 19:00:16 +0000 (20:00 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 12 Feb 2012 19:00:16 +0000 (20:00 +0100)
lib/CloudStore/JSON.pm [deleted file]
t/JSON.t [deleted file]

diff --git a/lib/CloudStore/JSON.pm b/lib/CloudStore/JSON.pm
deleted file mode 100644 (file)
index b757be1..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-package CloudStore::JSON;
-use warnings;
-use strict;
-
-use autodie;
-use JSON::XS;
-use File::Path qw();
-use File::Slurp qw();
-
-sub make_dir {
-       my ( $dir, $json ) = @_;
-       warn "### VFS make_dir $dir\n";
-       File::Path::make_path($dir);
-       $dir =~ s{/([^/]+)/?$}{/.$1};
-       File::Slurp::write_file $dir, $json if $json;
-}
-
-sub remove_dir {
-       warn "### VFS remove_dir $_[0]\n";
-       File::Path::remove_tree(@_);
-}
-
-sub remove_file {
-       warn "### VFS unlink $_[0]\n";
-       unlink $_[0];
-}
-
-sub write_file {
-       warn "### VFS ", -e $_[0] ? 'modify' : 'write', "_file $_[0]\n";
-       File::Slurp::write_file(@_);
-}
-
-sub read_file {
-       my $path = shift;
-       warn "### VFS read_file $path\n";
-       $path =~ s{/([^/]+)/?$}{/.$1} if -d $path;
-       File::Slurp::read_file($path);
-}
-
-sub rsync_transfer {
-       my ( $data ) = @_;
-       my $json = encode_json $data;
-
-       my $path = "users/$data->{login}/json/$data->{file}";
-
-       if ( $data->{itemize} =~ m/^[c>]([fd])/ ) { # received change/create
-               my $type = $1;
-
-               if ( $type eq 'f' ) {
-                       if ( $path =~ m{^(.+)/[^/]+$} ) { # have dir
-                               make_dir $1, $json if ! -e $1;
-                       }
-                       write_file $path, $json;
-               } elsif ( $type eq 'd' ) {
-                       make_dir $path, $json;
-               } else {
-                       die "unknown type $type";
-               }
-       } elsif ( $data->{itemize} =~ m/\*deleting/ ) {
-               if ( -d $path ) {
-                       remove_dir $path;
-               } elsif ( -f $path ) {
-                       remove_file $path;
-               } else {
-                       warn "ignored delete $path";
-               }
-       }
-       return $json;
-}
-
-sub file_data {
-       my $path = shift;
-       $path =~ s{/blob/}{/json/};
-       return decode_json read_file $path;
-}
-
-1;
diff --git a/t/JSON.t b/t/JSON.t
deleted file mode 100755 (executable)
index 01bb6f6..0000000
--- a/t/JSON.t
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/perl
-use strict;
-use warnings;
-
-use Test::More tests => 6;
-use Data::Dump qw(dump);
-
-use lib 'lib';
-
-use_ok 'CloudStore::JSON';
-
-CloudStore::JSON::remove_dir("users/test/blob/dir-test/bar");
-
-ok my $r = CloudStore::JSON::rsync_transfer(
-{
-  file       => "dir-test/bar",
-  itemize    => ">f+++++++++",
-  login      => "test",
-  md5        => "51ce99ec40129bfe1fd11d65b346d15e",
-  mtime      => "2011-07-17T17:55:15",
-  op         => "recv",
-  perms      => "rw-r--r--",
-  pid        => 29525,
-  port       => 6501,
-  size       => 10024,
-  timestamp  => "2011-07-17T17:55:15",
-  transfered => 10064,
-}
-), 'rsync_transfer';
-
-diag dump($r);
-
-ok $r = CloudStore::JSON::file_data('users/test/blob/dir-test/bar'), 'file_data';
-isa_ok $r, 'HASH';
-
-ok $r = CloudStore::JSON::file_data('users/test/blob/dir-test'), 'dir data';
-isa_ok $r, 'HASH';