Esempio n. 1
0
        private async Task LoopOverSidecarFiles(List <string> subPaths)
        {
            var parentDirectories = new HashSet <string>();
            var xmpSubPaths       = subPaths
                                    .Where(ExtensionRolesHelper.IsExtensionSidecar).ToList();

            foreach (var xmpPath in xmpSubPaths)
            {
                parentDirectories.Add(FilenamesHelper.GetParentPath(xmpPath));
            }

            var itemsInDirectories = new HashSet <FileIndexItem>(
                await _query.GetAllFilesAsync(parentDirectories.ToList()));

            // that is an filepath without extension
            var collectionPath = xmpSubPaths.Select(singlePath
                                                    => $"{FilenamesHelper.GetParentPath(singlePath)}/" +
                                                    FilenamesHelper.GetFileNameWithoutExtension(singlePath)).ToList();

            foreach (var item in itemsInDirectories)
            {
                foreach (var singleCollectionPath in collectionPath)
                {
                    if (item.FilePath.StartsWith(singleCollectionPath) &&
                        !ExtensionRolesHelper.IsExtensionSidecar(item.FilePath))
                    {
                        item.RemoveSidecarExtension("xmp");
                        await _query.UpdateItemAsync(item);
                    }
                }
            }

            Console.WriteLine();
        }
Esempio n. 2
0
        /// <summary>
        /// this updates the main database item for a sidecar file
        /// </summary>
        /// <param name="xmpSubPath">sidecar file</param>
        /// <param name="directoryWithFileIndexItems">directory where the sidecar is located</param>
        /// <returns>completed task</returns>
        private async Task UpdateSidecarFile(string xmpSubPath, List <FileIndexItem> directoryWithFileIndexItems)
        {
            if (!ExtensionRolesHelper.IsExtensionSidecar(xmpSubPath))
            {
                return;
            }
            var sidecarExt =
                FilenamesHelper.GetFileExtensionWithoutDot(xmpSubPath);

            foreach (var item in
                     directoryWithFileIndexItems.Where(item => !item.SidecarExtensionsList.Contains(sidecarExt)))
            {
                item.AddSidecarExtension(sidecarExt);
                await _query.UpdateItemAsync(item);
            }
        }
Esempio n. 3
0
        [ProducesResponseType(404)]         // not found
        public IActionResult DownloadSidecar(string f)
        {
            if (!ExtensionRolesHelper.IsExtensionSidecar(f))
            {
                return(NotFound("FileName is not a sidecar"));
            }

            if (!_iStorage.ExistFile(f))
            {
                return(NotFound($"source image missing {f}"));
            }

            var fs = _iStorage.ReadStream(f);

            return(File(fs, MimeHelper.GetMimeTypeByFileName(f)));
        }
Esempio n. 4
0
        /// <summary>
        /// Sidecar files don't have an own item, but there referenced by file items
        /// in the method xmp files are added to the AddSidecarExtension list.
        /// </summary>
        /// <param name="xmpSubPath">sidecar item</param>
        /// <returns>completed task</returns>
        public async Task UpdateSidecarFile(string xmpSubPath)
        {
            if (!ExtensionRolesHelper.IsExtensionSidecar(xmpSubPath))
            {
                return;
            }

            var parentPath = FilenamesHelper.GetParentPath(xmpSubPath);
            var fileNameWithoutExtension = FilenamesHelper.GetFileNameWithoutExtension(xmpSubPath);

            var directoryWithFileIndexItems = (await
                                               _query.GetAllFilesAsync(parentPath)).Where(
                p => p.ParentDirectory == parentPath &&
                p.FileCollectionName == fileNameWithoutExtension).ToList();

            await UpdateSidecarFile(xmpSubPath, directoryWithFileIndexItems);
        }