Example #1
0
        protected string CreateThumbsDir(string dbDataPath, long volumeID)
        {
            string volumeDataPath = DbData.CreateVolumeDataPath(dbDataPath, volumeID);

            volumeDataPaths.Add(volumeDataPath);
            return(DbData.CreateVolumeDataThumbsPath(volumeDataPath));
        }
        internal override void ScanningThreadMain(Platform.Common.IO.DriveInfo drive,
                                                  FileSystemVolume volume,
                                                  BufferedVolumeItemWriter writer)
        {
            try {
                if (Options.GenerateThumbnails)
                {
                    paths.volumeDataPath = DbData.CreateVolumeDataPath(paths.dbDataPath, volume.VolumeID);
                    paths.thumbnailPath  = DbData.CreateVolumeDataThumbsPath(paths.volumeDataPath);
                }

                string rootPath = drive.RootPath;
                // remove possible ending path seperator except for _system_ root paths
                rootPath = RemoveEndingSlash(rootPath);
                //			  if ((rootPath.Length > 1) && (rootPath[rootPath.Length - 1] == Path.DirectorySeparatorChar))
                //				  rootPath = rootPath.Substring(0, rootPath.Length - 1);

                // make sure the root path exists
                // (media may have been removed after scanner construction)
                if (!Directory.Exists(rootPath))
                {
                    throw new DirectoryNotFoundException("Root path does not exist");
                }

                DirectoryInfo dir = new DirectoryInfo(rootPath);
                RecursiveDump(rootPath, dir, writer, VolumeDatabase.ID_NONE);
                symLinkHelper.InsertSymLinkItems(writer, volume.VolumeID);

                volume.SetFileSystemVolumeFields(VolumeInfo.Files, VolumeInfo.Directories, VolumeInfo.Size);
            } catch (Exception) {
                // try to cleanup
                try {
                    if ((paths.volumeDataPath != null) && Directory.Exists(paths.volumeDataPath))
                    {
                        Directory.Delete(paths.volumeDataPath, true);
                    }
                } catch (Exception) { /* just shut up */ }

                // rethrow initial exception
                throw;
            }
        }