示例#1
0
        /// <summary>
        /// Execute -cp action for file f. Update database if needed.
        /// </summary>
        private void DownloadFiles(MediaDevice device, MediaFileInfo f, Dictionary <string, FileSpec> database)
        {
            var localFilename = Path.Combine(localFolder, f.Name.Substring(f.Name.LastIndexOf("\\") + 1));

            Console.Error.WriteLine("writing: " + localFilename); // DEBUG msg
            FileStream fs = File.Create(localFilename);

            device.DownloadFile(f.FullName, fs);

            FileSpec fspec = null;

            if (removeDuplicates || splitFolders)
            {
                fspec = new FileSpec(localFilename, f.CreationTime);
            }

            if (removeDuplicates)
            {
                if (database.ContainsKey(fspec.ContentHash()))
                {
                    Console.Error.WriteLine("ignoring duplicate file: " + localFilename);
                    File.Delete(localFilename);
                }
                else
                {
                    database[fspec.ContentHash()] = fspec;
                }
            }
        }
示例#2
0
 private string GuessSubfolderName(FileSpec f)
 {
     if (f.CreationTime == null)
     {
         return(Program.NODATE_SUBFOLDER);                        //could this really happen?
     }
     return(f.CreationTime.Value.ToString("yyyy-MM-DD"));
 }