Пример #1
0
        public override void Clean(IExecuteContext executeContext, BuilderContext builderContext, bool deleteOutput)
        {
            // try to retrieve result from one of the object store
            var commandHash = Command.ComputeCommandHash(executeContext);

            // If there was an error computing the hash, early exit
            if (commandHash == ObjectId.Empty)
            {
                return;
            }

            var commandResultsFileStream = executeContext.ResultMap.OpenStream(commandHash, VirtualFileMode.OpenOrCreate, VirtualFileAccess.ReadWrite, VirtualFileShare.ReadWrite);
            var commandResultEntries     = new ListStore <CommandResultEntry>(commandResultsFileStream)
            {
                AutoLoadNewValues = false
            };

            commandResultEntries.LoadNewValues();
            commandResultsFileStream.Close();

            CommandResultEntry matchingResult = FindMatchingResult(executeContext, commandResultEntries.GetValues());

            if (matchingResult != null)
            {
                if (deleteOutput)
                {
                    foreach (KeyValuePair <ObjectUrl, ObjectId> outputObject in matchingResult.OutputObjects)
                    {
                        switch (outputObject.Key.Type)
                        {
                        case UrlType.File:
                            try
                            {
                                if (File.Exists(outputObject.Key.Path))
                                {
                                    File.Delete(outputObject.Key.Path);
                                }
                            }
                            catch (Exception)
                            {
                                executeContext.Logger.Error("Unable to delete file: " + outputObject.Key.Path);
                            }
                            break;

                        case UrlType.Content:
                            executeContext.ResultMap.Delete(outputObject.Value);
                            break;
                        }
                    }
                }
            }

            executeContext.ResultMap.Delete(commandHash);
        }
Пример #2
0
        private void RegisterCommandResult(ListStore <CommandResultEntry> commandResultEntries, CommandResultEntry result, ResultStatus status)
        {
            //foreach (var outputObject in result.OutputObjects.Where(outputObject => outputObject.Key.Type == UrlType.Internal))
            //{
            //    builderContext.contentIndexMap[outputObject.Key.Path] = outputObject.Value;
            //}

            Result = result;

            // Only save to build cache if compilation was done and successful
            if (status == ResultStatus.Successful)
            {
                commandResultEntries.AddValue(result);
            }
        }
Пример #3
0
        internal bool ShouldExecute(IExecuteContext executeContext, CommandResultEntry[] previousResultCollection, ObjectId commandHash, out CommandResultEntry matchingResult)
        {
            var outputObjectsGroups = executeContext.GetOutputObjectsGroups();

            MicrothreadLocalDatabases.MountDatabase(outputObjectsGroups);
            try
            {
                matchingResult = FindMatchingResult(executeContext, previousResultCollection);
            }
            finally
            {
                MicrothreadLocalDatabases.UnmountDatabase();
            }

            if (matchingResult == null || Command.ShouldForceExecution())
            {
                // Ensure we ignore existing results if the execution is forced
                matchingResult = null;
                return(true);
            }

            return(false);
        }
Пример #4
0
 protected CommandContextBase(Command command, BuilderContext builderContext)
 {
     CurrentCommand = command;
     ResultEntry    = new CommandResultEntry();
 }