Пример #1
0
        protected void ScanPhotoDirectory(ImportController controller, SafeUri uri, PhotoList photo_list)
        {
            var enumerator = new RecursiveFileEnumerator(uri)
            {
                Recurse        = controller.RecurseSubdirectories,
                CatchErrors    = true,
                IgnoreSymlinks = true
            };

            foreach (var file in enumerator)
            {
                if (ImageFile.HasLoader(new SafeUri(file.Uri.ToString(), true)))
                {
                    var info = new FileImportInfo(new SafeUri(file.Uri.ToString(), true));
                    ThreadAssist.ProxyToMain(() =>
                                             photo_list.Add(info));
                }
                if (!run_photoscanner)
                {
                    return;
                }
            }
        }
Пример #2
0
        protected void ScanPhotoDirectory(ImportController controller, SafeUri uri, PhotoList photo_list)
        {
            var enumerator = new RecursiveFileEnumerator(uri)
            {
                Recurse        = controller.RecurseSubdirectories,
                CatchErrors    = true,
                IgnoreSymlinks = true
            };
            var infos = new List <FileImportInfo> ();

            foreach (var file in enumerator)
            {
                if (ImageFile.HasLoader(new SafeUri(file.Uri.ToString(), true)))
                {
                    infos.Add(new FileImportInfo(new SafeUri(file.Uri.ToString(), true)));
                }

                if (infos.Count % 10 == 0 || infos.Count < 10)
                {
                    var to_add = infos;                     // prevents race condition
                    ThreadAssist.ProxyToMain(() => photo_list.Add(to_add.ToArray()));
                    infos = new List <FileImportInfo> ();
                }

                if (!run_photoscanner)
                {
                    return;
                }
            }

            if (infos.Count > 0)
            {
                var to_add = infos;                 // prevents race condition
                ThreadAssist.ProxyToMain(() => photo_list.Add(to_add.ToArray()));
            }
        }
Пример #3
0
 protected void ScanPhotoDirectory(ImportController controller, SafeUri uri, PhotoList photo_list)
 {
     var enumerator = new RecursiveFileEnumerator (uri) {
                 Recurse = controller.RecurseSubdirectories,
                 CatchErrors = true,
                 IgnoreSymlinks = true
     };
     foreach (var file in enumerator) {
         if (ImageFile.HasLoader (new SafeUri (file.Uri.ToString(), true))) {
             var info = new FileImportInfo (new SafeUri (file.Uri.ToString (), true));
             ThreadAssist.ProxyToMain (() =>
                 photo_list.Add (info));
         }
         if (!run_photoscanner)
             return;
     }
 }
Пример #4
0
        protected void ScanPhotoDirectory(ImportController controller, SafeUri uri, PhotoList photo_list)
        {
            var enumerator = new RecursiveFileEnumerator (uri) {
                        Recurse = controller.RecurseSubdirectories,
                        CatchErrors = true,
                        IgnoreSymlinks = true
            };
            var infos = new List<FileImportInfo> ();
            foreach (var file in enumerator) {
                if (ImageFile.HasLoader (new SafeUri (file.Uri.ToString(), true))) {
                    infos.Add (new FileImportInfo (new SafeUri (file.Uri.ToString(), true)));
                }

                if (infos.Count % 10 == 0 || infos.Count < 10) {
                    var to_add = infos; // prevents race condition
                    ThreadAssist.ProxyToMain (() => photo_list.Add (to_add.ToArray ()));
                    infos = new List<FileImportInfo> ();
                }

                if (!run_photoscanner)
                    return;
            }

            if (infos.Count > 0) {
                var to_add = infos; // prevents race condition
                ThreadAssist.ProxyToMain (() => photo_list.Add (to_add.ToArray ()));
            }
        }