예제 #1
0
        protected override IMedia AddMediaFromPath(string fullPath, DateTime lastUpdated)
        {
            if (!AcceptFile(fullPath))
            {
                return(null);
            }
            if (FindMediaFirstByFullPath(fullPath) is ServerMedia newMedia)
            {
                return(newMedia);
            }
            var relativeName = fullPath.Substring(Folder.Length);
            var fileName     = Path.GetFileName(relativeName);
            var mediaType    = FileUtils.VideoFileTypes.Contains(Path.GetExtension(fullPath).ToLowerInvariant()) ? TMediaType.Movie : TMediaType.Still;

            newMedia = new ServerMedia
            {
                MediaName   = FileUtils.GetFileNameWithoutExtension(fullPath, mediaType),
                LastUpdated = lastUpdated,
                MediaType   = mediaType,
                MediaGuid   = Guid.NewGuid(),
                FileName    = Path.GetFileName(relativeName),
                Folder      = relativeName.Substring(0, relativeName.Length - fileName.Length).Trim(PathSeparator),
            };
            AddMedia(newMedia);
            newMedia.Save();
            return(newMedia);
        }
예제 #2
0
        internal void ArchiveSave(ServerMedia media, bool deleteAfterSuccess)
        {
            ArchiveMedia archived;

            if (media.IsArchived &&
                (archived = EngineController.Database.ArchiveMediaFind <ArchiveMedia>(this, media.MediaGuid)) != null &&
                archived.FileExists())
            {
                if (deleteAfterSuccess)
                {
                    MediaManager.FileManager.Queue(new FileOperation((FileManager)MediaManager.FileManager)
                    {
                        Kind = TFileOperationKind.Delete, Source = media
                    });
                }
            }
            else
            {
                _archiveCopy(media, this, deleteAfterSuccess);
            }
        }
예제 #3
0
        internal void ArchiveSave(ServerMedia media, bool deleteAfterSuccess)
        {
            var archived = DatabaseProvider.Database.ArchiveMediaFind <ArchiveMedia>(this, media.MediaGuid);

            if (archived != null)
            {
                archived.Directory = this;
            }

            if (deleteAfterSuccess && archived?.FileExists() == true)
            {
                FileManager.Current.Queue(
                    new DeleteOperation {
                    Source = media
                });
                return;
            }
            if (archived?.FileExists() != true)
            {
                _archiveCopy(media, this, deleteAfterSuccess);
            }
        }