Beispiel #1
0
        public Index (string database_path, string checkout_path, User user)
        {
            DatabasePath = database_path;
            CheckoutPath = checkout_path;

            HashObject.DatabasePath = DatabasePath;
        }
Beispiel #2
0
        public static void Main (string [] args)
        {

            Console.WriteLine (File.GetLastWriteTimeUtc ("/home/hbons/test.txt").GetHashCode ());
            Environment.Exit (0);




            User user = new User {
                Name  = "Hylke Bons",
                Email = "*****@*****.**"
            };

            Index index = new Index ("/Users/hbons/SparkleShare/Rainbows/.sparkleshare",
                "/Users/hbons/SparkleShare/Rainbows", user);

            //index.Status ();
            //index.Commit ();


            //Index.Clone (new Uri ("ssh://[email protected]/home/sites/webhosting/bomahy/bomahy/test.sparkleshare"),
              //  "/home/hbons/TEST");

            TransferManager t = new TransferManager ("/home/hbons/TEST/db",
                new Uri ("ssh://[email protected]/home/sites/webhosting/bomahy/bomahy/test.sparkleshare"));

            t.UploadObject ("12124");
            t.UploadObject ("12125");
            t.UploadObject ("12126");
            t.UploadObject ("12127");
            t.UploadObject ("12128");
            t.UploadObject ("12129");
            t.UploadObject ("12130");
            t.UploadObject ("12131");
            t.UploadObject ("12132");
            t.UploadObject ("12133");
            t.UploadObject ("12134");
            t.UploadObject ("12135");
            t.UploadObject ("12136");
            t.UploadObject ("12137");
            t.UploadObject ("12138");
            t.UploadObject ("12139");
            t.UploadObject ("12140");
            t.DownloadObject ("12126");


        }
Beispiel #3
0
        public void Commit ()
        {
            Chunker chunker = new Chunker (DatabasePath);
            chunker.ChunkCrypto = new Crypto ("cGFzc3dvcmQAAAAAAAAAAA==");

            // Tell the chunker to save in our database format
            chunker.NameChunk = delegate (string chunk_file_name) {
                string hash            = chunk_file_name;
                string chunk_container = hash.Substring (0, 2);
                chunk_file_name        = hash.Substring (2);

                return Path.Combine (chunker.OutputDirectory, chunk_container, chunk_file_name);
            };

            // TransferManager transfer_manager = new TransferManager (
            // DatabasePath, "/Users/hbons/rsync-test");

            chunker.ChunkCreated += delegate (string chunk_file_path, int chunk_size,
                                              string chunk_hash) {
              // add hash to "todo" transfer list
              //transfer_manager.UploadObject (chunk_file_path);
              // remove hash to "todo" transfer list
            };


            //chunker.Finished += delegate (Chunk [] chunks) {
              //  Blob blob = Blob.Write (chunks);
            //};

            // TODO: needs to block


            chunker.FileToChunks ("/Users/hbons/hp2.avi", 4 * 1024 * 1024);

            User author = new User { Name = "Hylke Bons", Email = "*****@*****.**" };












            Objects.Commit.Write (author, DateTime.UtcNow, Head, null);

            // TODO: Walk the new tree and create blobs, trees, commit
            //
            // foreach
            //   Hashtable trees = new Hashtable ();
            //   Hashtable blobs = new Hashtable ();
            //   trees.Add ("", new Tree ());
            //   blobs.Add ("", new Blob ());
            // - Upload all trees and blobs
            //   Tree tree = new Tree ("123456");
            // transfer_manager.UploadObject ("12345");
            //
            // tree.Trees = trees;
            // tree.Blobs = blobs;
            //
            // Commit commit    = new Commit ("abcdef");
            // commit.Tree      = tree;
            // commit.Author    = user.Name;
            // commit.Email     = user.Email;
            // commit.Timestamp = DateTime.UtcNow;
            //
            // transfer_manager.UploadObject ("abcdef");
            // - Update HEAD file
        }