Example #1
0
        public bool IsPathLocked(string path)
        {
            // This method is not used by the core but it used by auto-organize

            var lockedPaths = _tempIgnoredPaths.Keys.ToList();

            return(lockedPaths.Any(i => _fileSystem.AreEqual(i, path) || _fileSystem.ContainsSubPath(i, path)));
        }
Example #2
0
        public void ReportFileSystemChanged(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }

            var filename = Path.GetFileName(path);

            var monitorPath = !string.IsNullOrEmpty(filename) &&
                              !_alwaysIgnoreFiles.Contains(filename, StringComparer.OrdinalIgnoreCase) &&
                              !_alwaysIgnoreExtensions.Contains(Path.GetExtension(path) ?? string.Empty, StringComparer.OrdinalIgnoreCase) &&
                              _alwaysIgnoreSubstrings.All(i => path.IndexOf(i, StringComparison.OrdinalIgnoreCase) == -1);

            // Ignore certain files
            var tempIgnorePaths = _tempIgnoredPaths.Keys.ToList();

            // If the parent of an ignored path has a change event, ignore that too
            if (tempIgnorePaths.Any(i =>
            {
                if (_fileSystem.AreEqual(i, path))
                {
                    Logger.Debug("Ignoring change to {0}", path);
                    return(true);
                }

                if (_fileSystem.ContainsSubPath(i, path))
                {
                    Logger.Debug("Ignoring change to {0}", path);
                    return(true);
                }

                // Go up a level
                var parent = _fileSystem.GetDirectoryName(i);
                if (!string.IsNullOrEmpty(parent))
                {
                    if (_fileSystem.AreEqual(parent, path))
                    {
                        Logger.Debug("Ignoring change to {0}", path);
                        return(true);
                    }
                }

                return(false);
            }))
            {
                monitorPath = false;
            }

            if (monitorPath)
            {
                // Avoid implicitly captured closure
                CreateRefresher(path);
            }
        }
Example #3
0
        internal Task EnsureLibraryFolder(string path, string name)
        {
            var existingFolders = _libraryManager
                                  .RootFolder
                                  .Children
                                  .OfType <Folder>()
                                  .Where(i => _fileSystem.AreEqual(path, i.Path) || _fileSystem.ContainsSubPath(i.Path, path))
                                  .ToList();

            if (existingFolders.Count > 0)
            {
                return(Task.CompletedTask);
            }

            _fileSystem.CreateDirectory(path);

            var libraryOptions = new LibraryOptions
            {
                PathInfos = new[] { new MediaPathInfo {
                                        Path = path
                                    } },
                EnablePhotos          = true,
                EnableRealtimeMonitor = false,
                SaveLocalMetadata     = true
            };

            if (string.IsNullOrWhiteSpace(name))
            {
                name = _localizationManager.GetLocalizedString("HeaderCameraUploads");
            }

            return(_libraryManager.AddVirtualFolder(name, CollectionType.HomeVideos, libraryOptions, true));
        }
Example #4
0
        private static void EnsureDates(IFileSystem fileSystem, BaseItem item, ItemResolveArgs args)
        {
            // See if a different path came out of the resolver than what went in
            if (!fileSystem.AreEqual(args.Path, item.Path))
            {
                var childData = args.IsDirectory ? args.GetFileSystemEntryByPath(item.Path) : null;

                if (childData != null)
                {
                    SetDateCreated(item, childData);
                }
                else
                {
                    var fileData = fileSystem.GetFileSystemInfo(item.Path);

                    if (fileData.Exists)
                    {
                        SetDateCreated(item, fileData);
                    }
                }
            }
            else
            {
                SetDateCreated(item, args.FileInfo);
            }
        }
Example #5
0
 private IEnumerable <Folder> FindFolders(string path)
 {
     return(_libraryManager
            .RootFolder
            .Children
            .OfType <Folder>()
            .Where(i => _fileSystem.AreEqual(path, i.Path) || _fileSystem.ContainsSubPath(i.Path, path)));
 }
Example #6
0
 public bool Equals(LinkedChild x, LinkedChild y)
 {
     if (x.Type == y.Type)
     {
         return(_fileSystem.AreEqual(x.Path, y.Path));
     }
     return(false);
 }