Exemplo n.º 1
0
        /// <summary>
        /// Generates the delta file. Based off the new file and signature file.
        /// </summary>
        /// <returns>The delta file.</returns>
        /// <param name="signaturePath">Signature path.</param>
        /// <param name="newFilePath">New file path.</param>
        /// <param name="saveDeltaLocation">Save delta location.</param>
        public string generateDeltaFile(string signaturePath, string newFilePath, string saveDeltaLocation = "")
        {
            curProcessDone = false;
            currentProcess = "Generating delta file for " + Path.GetFileName(newFilePath);
            //newFilePath could be a remote file as well
            try
            {
                if (string.IsNullOrEmpty(saveDeltaLocation) == true)                                    //generate save location
                {
                    string[] fileInfo = octodiffFilePathInfo(newFilePath);
                    saveDeltaLocation = fileInfo[1];
                }
                saveDeltaLocation = saveDeltaLocation.Trim();                                                   //remove line endings

                //Usage: Octodiff delta <signature-file> <new-file> [<delta-file>] [<options>]
                string[]     commands = { signaturePath, newFilePath, saveDeltaLocation };        //add correct arguments
                DeltaCommand command  = new DeltaCommand();
                command.Execute(commands);                                                        //generate delta file
            }
            catch (Exception ex)
            {
                currentProcess   = "";
                currentException = ex.Message;
                return(ex.Message);
            }
            currentProcess = "";
            curProcessDone = true;
            return("Success");
        }
Exemplo n.º 2
0
        private void OnHandleDecrement(DeltaCommand command)
        {
            var item           = command.Item;
            var commandContext = new CommandContext(command, item);
            var key            = ProcessItemAndBuildKey(commandContext);
            var result         = _memcachedClient.Decrement(key, command.Delta);

            command.SetResult(result);
        }
Exemplo n.º 3
0
 public void Read(BufferReader reader)
 {
     command = (DeltaCommand)reader.ReadInt16();
     reader.Skip(2); // unknown
     offset = reader.ReadInt32();
     length = reader.ReadInt32();
     if (command == DeltaCommand.WriteLog)
     {
         data = reader.GetBytes(length);
     }
 }
Exemplo n.º 4
0
 public void Read(BufferReader reader)
 {
     command = (DeltaCommand)reader.ReadInt16();
     reader.Skip(2); // unknown
     offset = reader.ReadInt32();
     length = reader.ReadInt32();
     if (command == DeltaCommand.WriteLog)
     {
         data = reader.GetBytes(length);
     }
 }
Exemplo n.º 5
0
 public when_incrementing_item_in_cache_and_operation_fails()
 {
     Given(() => item_is_handled_and_key_generated("simplekey"));
     Given(() => item_delta_fails("simplekey", 2));
     When(() => result = DoDelta(item => item.KeyIs("nomatter"), 2));
 }
Exemplo n.º 6
0
 public when_incrementing_item_in_cache_and_operation_succeeds()
 {
     Given(() => item_is_handled_and_key_generated("simplekey"));
     Given(() => item_delta_in_performed_sucessfully("simplekey", 2, 14));
     When(() => result = DoDelta(item => item.KeyIs("nomatter"), 2));
 }