cupscale icon indicating copy to clipboard operation
cupscale copied to clipboard

Error during FilenamePostprocess(): Cannot create a file when that file already exists.

Open MiLO83 opened this issue 4 years ago • 4 comments

Error during FilenamePostprocess():

Cannot create a file when that file already exists.

Stack Trace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.File.InternalMove(String sourceFileName, String destFileName, Boolean checkHost) at Cupscale.Main.Upscale.FilenamePostprocess(String file)

MiLO83 avatar Aug 25 '21 04:08 MiLO83

Tell me the exact steps to reproduce the error.

n00mkrad avatar Aug 25 '21 16:08 n00mkrad

I did a very large batch of 14,000 images, I let it sit at post-processing for 2 hours. there was no progress indicator and I gave up and force quit. I decided to start over and let it run again overnight, but got this error I assume 14,000 times :) How do I clean Install Cupscale (Manually?) Couldn't you just delete the old file if the file exists before create? THANKS! I LOVE CUPSCALE! IT'S GREAT! :)

MiLO83 avatar Aug 26 '21 06:08 MiLO83

public static string FilenamePostprocess(string file)
        {
            if (Program.canceled) return null;

            try
            {
                string newFilename = file;
                string pathNoExt = Path.ChangeExtension(file, null);
                string ext = Path.GetExtension(file);

                newFilename = pathNoExt + "-" + GetLastModelName() + ext;
                Logger.Log($"FilenamePostprocess: Moving {file} => {newFilename}");

                if (File.Exists(newFilename)) // Added this..
                    File.Delete(newFilename); // and this.

                File.Move(file, newFilename);
                newFilename = IoUtils.RenameExtension(newFilename, "jpg", Config.Get("jpegExtension"));

                return newFilename;
            }
            catch (Exception e)
            {
                Logger.ErrorMessage("Error during FilenamePostprocess(): ", e);
                return null;
            }
        }

MiLO83 avatar Aug 27 '21 01:08 MiLO83

the batch of files you were working on were set to read only

Randalmcdaniel avatar Feb 18 '22 23:02 Randalmcdaniel