/// <summary> /// Computes a unique hash for the target logset. /// </summary> public static string ComputeLogsetHash(LogsharkRequestTarget target) { if (target.IsHashId) { return(target); } Log.Info("Computing Logset Hash.."); string logsetHash = LogsetHashUtil.GetLogSetHash(target); Log.InfoFormat("Logset hash is '{0}'.", logsetHash); return(logsetHash); }
internal LogsharkRequestTarget(string requestedTarget) { if (String.IsNullOrWhiteSpace(requestedTarget)) { throw new InitializationException("Invalid request: No logset target specified!"); } // A target can either be an MD5 logset hash or a file/UNC path. if (PathHelper.IsPathToExistingResource(requestedTarget)) { // If target is a file or directory, we want to use the absolute path and trim any trailing // directory separator characters to establish consistency. string absolutePath = PathHelper.GetAbsolutePath(requestedTarget); if (PathHelper.IsDirectory(absolutePath)) { IsDirectory = true; UncompressedSize = DiskSpaceHelper.GetDirectorySize(absolutePath); } else { IsFile = true; UncompressedSize = 0; CompressedSize = DiskSpaceHelper.GetFileSize(absolutePath); } Target = absolutePath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); } else if (LogsetHashUtil.IsValidMD5(requestedTarget)) { // Since this isn't a path to a file or directory and it looks like an MD5, we assume it is. IsHashId = true; Target = requestedTarget; } else { throw new InitializationException("Target must be a valid file, directory or MD5 hash!"); } OriginalTarget = Target; }
private LogsharkRequest BuildLogsharkRequest(LogsharkCommandLineOptions commandLineArgs) { string target = commandLineArgs.Target; if (String.IsNullOrWhiteSpace(target)) { throw new ArgumentException("No logset target specified! See 'logshark --help' for usage examples."); } // If the target is a relative path, we first need to convert it to an absolute path. if (!LogsetHashUtil.IsValidMD5(target) && !Path.IsPathRooted(target)) { target = Path.Combine(currentWorkingDirectory, target); } var request = new LogsharkRequestBuilder(target, configuration) .WithProjectDescription(commandLineArgs.ProjectDescription) .WithProjectName(commandLineArgs.ProjectName) .WithSiteName(commandLineArgs.SiteName) .WithPostgresDatabaseName(commandLineArgs.DatabaseName) .WithForceParse(commandLineArgs.ForceParse) .WithProcessDebug(commandLineArgs.ProcessDebug) .WithDropParsedLogset(commandLineArgs.DropParsedLogset) .WithPublishWorkbooks(commandLineArgs.PublishWorkbooks) .WithMetadata(ParseCommandLineArgToDictionary(commandLineArgs.Metadata)) .WithWorkbookTags(commandLineArgs.WorkbookTags) .WithPluginsToExecute(commandLineArgs.Plugins) .WithPluginCustomArguments(ParseCommandLineArgToDictionary(commandLineArgs.CustomArgs)) .WithProcessFullLogset(commandLineArgs.ParseAll) .WithStartLocalMongo(commandLineArgs.StartLocalMongo) .WithLocalMongoPort(commandLineArgs.LocalMongoPort) .WithSource("CLI") .GetRequest(); return(request); }
// Custom hashing function for this artifact type. Typically this returns an MD5-style hash value. public string ComputeArtifactHash(LogsharkRequest request) { // TODO: Verify that the following default is sufficiently unique for this payloads of this artifact type, or implement custom hash logic. return(LogsetHashUtil.GetLogSetHash(request.Target)); }
// Custom hashing function for this artifact type. Typically this returns an MD5-style hash value. public string ComputeArtifactHash(LogsharkRequest request) { return(LogsetHashUtil.GetLogSetHash(request.Target)); }