Пример #1
0
        public void MapFileTypesToExtension_fileWithNonExistingExtension()
        {
            var result = ExtensionRolesHelper.MapFileTypesToExtension("non.ext");

            Assert.AreEqual(ExtensionRolesHelper.ImageFormat.unknown, result);
        }
Пример #2
0
        public void MapFileTypesToExtension_Null()
        {
            var result = ExtensionRolesHelper.MapFileTypesToExtension(null);

            Assert.AreEqual(ExtensionRolesHelper.ImageFormat.unknown, result);
        }
Пример #3
0
        public List <FileIndexItem> GetInfo(List <string> inputFilePaths, bool collections)
        {
            // the result list
            var fileIndexResultsList = new List <FileIndexItem>();

            foreach (var subPath in inputFilePaths)
            {
                var detailView = _query.SingleItem(subPath, null, collections, false);

                if (detailView?.FileIndexItem == null)
                {
                    StatusCodesHelper.ReturnExifStatusError(new FileIndexItem(subPath),
                                                            FileIndexItem.ExifStatus.NotFoundNotInIndex,
                                                            fileIndexResultsList);
                    continue;
                }

                if (!_iStorage.ExistFile(detailView.FileIndexItem.FilePath))
                {
                    StatusCodesHelper.ReturnExifStatusError(detailView.FileIndexItem,
                                                            FileIndexItem.ExifStatus.NotFoundSourceMissing,
                                                            fileIndexResultsList);
                    continue;
                }

                // Check if extension is supported for ExtensionExifToolSupportedList
                // Not all files are able to write with exifTool
                if (!ExtensionRolesHelper.IsExtensionExifToolSupported(detailView.FileIndexItem.FileName))
                {
                    StatusCodesHelper.ReturnExifStatusError(
                        new FileIndexItemJsonParser(_iStorage).Read(detailView.FileIndexItem),
                        FileIndexItem.ExifStatus.ExifWriteNotSupported,
                        fileIndexResultsList);
                    continue;
                }

                var statusResults = StatusCodesHelper.IsDeletedStatus(detailView);
                // only when default status to avoid unneeded checks
                if (statusResults == FileIndexItem.ExifStatus.Default)
                {
                    statusResults = _statusCodeHelper.IsReadOnlyStatus(detailView);
                }
                // when everything is checked, it should be good
                if (statusResults == FileIndexItem.ExifStatus.Default)
                {
                    statusResults = FileIndexItem.ExifStatus.Ok;
                }

                var collectionSubPathList = DetailView.GetCollectionSubPathList(detailView.FileIndexItem, collections, subPath);

                foreach (var collectionSubPath in collectionSubPathList)
                {
                    var collectionItem = _readMeta.ReadExifAndXmpFromFile(collectionSubPath);

                    collectionItem.Status          = statusResults;
                    collectionItem.CollectionPaths = collectionSubPathList;
                    collectionItem.ImageFormat     =
                        ExtensionRolesHelper.MapFileTypesToExtension(collectionSubPath);
                    collectionItem.Size = _iStorage.Info(collectionSubPath).Size;
                    fileIndexResultsList.Add(collectionItem);
                }
            }

            return(fileIndexResultsList);
        }