Beispiel #1
0
        private FilePath GetUniqueImageFilePath(ImageFileIdentity imageFileIdentity)
        {
            var uniqueImageFileName = imageFileIdentity.GetUniqueFileName();

            var uniqueImageFilePath = this.GetUniqueImageFilePath(uniqueImageFileName);

            return(uniqueImageFilePath);
        }
Beispiel #2
0
        /// <summary>
        /// This, in context, means the original image file name.
        /// </summary>
        public async Task <FileName> GetImageFileName(ImageFileIdentity imageFileIdentity)
        {
            // Can get the unique image file-name directly from the image file identity.
            var uniqueImageFileName = imageFileIdentity.GetUniqueFileName();

            var originalImageFileName = await this.OriginalFileNameMappingRepository.GetOriginalImageFileName(uniqueImageFileName);

            return(originalImageFileName);
        }
Beispiel #3
0
        public async Task Delete(ImageFileIdentity imageFileIdentity)
        {
            var uniqueImageFileName = imageFileIdentity.GetUniqueFileName();
            var uniqueImageFilePath = this.GetUniqueImageFilePath(uniqueImageFileName);

            // The multiple tasks are sequentially awaited to allow failures to preserve the sequence of events in case of failure.
            // (The alternative would have been to Task.WhenAll() the various tasks, which would be simultaneous, but would lead to situations where things might get out of whack in case of failure.)

            // Delete the image file.
            await FileHelper.DeleteAsync(uniqueImageFilePath.Value);

            // Remove the local file info.
            var fileIdentity = imageFileIdentity.GetFileIdentity();

            await this.LocalFileInfoRepository.Delete(fileIdentity);

            // Delete the original image name mapping.

            await this.OriginalFileNameMappingRepository.Delete(uniqueImageFileName);
        }