public BatchResult Execute(StorageActions storage)
 {
     storage.Delete(Key, Etag);
     return(new BatchResult
     {
         Key = Key,
     });
 }
Example #2
0
        public BatchResult Execute(StorageActions storage)
        {
            var guid = storage.Add(Key, Metadata.Value <string>(Constants.RavenEntityName) ?? "", Etag, Metadata, Document);

            return(new BatchResult
            {
                Etag = guid,
                Key = Key,
            });
        }
Example #3
0
        public StorageActions ItemDiff(StorageItem item, StorageItem original)
        {
            StorageActions actions = StorageActions.None;

            if (original == null)
            {
                return(StorageActions.Created);
            }

            if (item.Name != original.Name)
            {
                actions = actions | StorageActions.Renamed;
            }

            if (ScopeChanged(item.Scope, original.Scope))
            {
                actions = actions | StorageActions.Scoped;
            }

            if (item.IsFlagged(StorageFlags.Archived) && !original.IsFlagged(StorageFlags.Archived))
            {
                actions = actions | StorageActions.Deleted;
            }

            if (!item.IsFlagged(StorageFlags.Archived) && original.IsFlagged(StorageFlags.Archived))
            {
                actions = actions | StorageActions.Restored;
            }

            if (item.GetType() == typeof(StorageFile))
            {
                if (!Utilities.MemCompare(((StorageFile)item).InternalHash, ((StorageFile)original).InternalHash))
                {
                    actions = actions | StorageActions.Modified;
                }
            }


            return(actions);
        }
Example #4
0
        RecordHeader StoreToStream(Stream dataStream, string key, string table, byte[] data,
                                   StorageActions storageAction)
        {
            int recordSize = data == null ? 0 : data.Length;
            var header     = new RecordHeader
            {
                Key        = key,
                Table      = table,
                Action     = storageAction,
                RecordSize = recordSize
            };

            dataStream.SeekEnd();
            dataStream.WriteRecordHeader(header);

            header.RecordLocation = dataStream.Position;

            if (data != null)
            {
                dataStream.Write(data);
            }

            return(header);
        }