Example #1
0
        /// <summary>
        /// Find the service from the path.
        /// </summary>
        public static ServiceNames GetServiceName(ISleetFile file)
        {
            var path = GetRelativePath(file).Trim('/').Split('/')[0].ToLowerInvariant();

            switch (path)
            {
            case "badges":
                return(ServiceNames.Badges);

            case "registration":
                return(ServiceNames.Registrations);

            case "catalog":
                return(ServiceNames.Catalog);

            case "autocomplete":
                return(ServiceNames.AutoComplete);

            case "search":
                return(ServiceNames.Search);

            case "symbols":
                return(ServiceNames.Symbols);

            default:
                return(ServiceNames.Unknown);
            }
        }
Example #2
0
 public PackageFile(string fileName, string hash, ZipArchiveEntry zipEntry, ISleetFile assetFile, ISleetFile indexFile)
 {
     AssetFile = assetFile;
     FileName  = fileName;
     Hash      = hash;
     ZipEntry  = zipEntry;
     IndexFile = indexFile;
 }
Example #3
0
 public PackageFile(string fileName, string hash, MemoryStream stream, ISleetFile assetFile, ISleetFile indexFile)
 {
     AssetFile = assetFile;
     FileName  = fileName;
     Hash      = hash;
     Stream    = stream;
     IndexFile = indexFile;
 }
Example #4
0
        /// <summary>
        /// file/hash/index -> package
        /// </summary>
        private Task AddAssemblyToPackageIndexAsync(PackageInput package, ISleetFile indexFile, bool isSymbolsPackage)
        {
            var index = new PackageIndexFile(_context, indexFile, persistWhenEmpty: false);

            if (isSymbolsPackage)
            {
                return(index.AddSymbolsPackageAsync(package));
            }
            else
            {
                return(index.AddPackageAsync(package));
            }
        }
Example #5
0
        /// <summary>
        /// Get the relative path of a file
        /// </summary>
        public static string GetRelativePath(ISleetFile file)
        {
            if (file is null)
            {
                throw new ArgumentNullException(nameof(file));
            }

            var fileSystemBase = file.FileSystem as FileSystemBase;

            if (fileSystemBase != null)
            {
                return(fileSystemBase.GetRelativePath(file.EntityUri));
            }
            else
            {
                return(UriUtility.GetRelativePath(file.FileSystem.BaseURI, file.EntityUri));
            }
        }
Example #6
0
 private static Func <Task> GetCommitFileFunc(ISleetFile file, ILogger log, CancellationToken token)
 {
     return(new Func <Task>(() => file.Push(log, token)));
 }
Example #7
0
 public PackageIndexFile(SleetContext context, ISleetFile file, bool persistWhenEmpty)
     : base(context, file, persistWhenEmpty)
 {
 }
Example #8
0
 public static PerfEntryWrapper <PerfFileEntry> CreateModifyTimer(ISleetFile file, SleetContext context)
 {
     return(CreateModifyTimer(file, context.PerfTracker));
 }
Example #9
0
 public static PerfEntryWrapper <PerfFileEntry> CreateFileTimer(ISleetFile file, IPerfTracker tracker, PerfFileEntry.FileOperation operation)
 {
     return(new PerfEntryWrapper <PerfFileEntry>(tracker, (time) => new PerfFileEntry(time, file.EntityUri, operation)));
 }
Example #10
0
 public static PerfEntryWrapper <PerfFileEntry> CreateModifyTimer(ISleetFile file, IPerfTracker tracker)
 {
     return(CreateFileTimer(file, tracker, PerfFileEntry.FileOperation.Modify));
 }
Example #11
0
 protected IndexFileBase(SleetContext context, ISleetFile file, bool persistWhenEmpty)
 {
     Context          = context ?? throw new ArgumentNullException(nameof(context));
     File             = file ?? throw new ArgumentNullException(nameof(file));
     PersistWhenEmpty = persistWhenEmpty;
 }