Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 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()));
            }
        }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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 ()));
            }
        }