Skip to content
TheChatArchiveThe Chat Archive
gpt-4.1-mini-2025-04-14· OpenAIAi2 WildChat-4.8M (AI2)

private void button4_Click(object sender, EventArgs e) { string FishHome =…

  1. User

    private void button4_Click(object sender, EventArgs e) { string FishHome = @"C:\AI\fish-speech"; string ResultsHome = FishHome + @"\results"; string RecentModelFolder = PrintMostRecentFolderName(ResultsHome); string Checkpoints = ResultsHome + RecentModelFolder + @"\checkpoints";

    // I need functionality here that will warn the user if it's ok or not to override their existing checkpoint
    // 1. The 'checkpoints' directory path is constructed and ready named 'string Checkpoints'.
    // 2. The most recent folder in 'checkpoints' can be found using PrintMostRecentFolderName(Checkpoints);
    // 3. Delete the most recent folder in checkpoints and it's files, do not delete fish-speech-1.5 in the folder.
    
    MergeLora("fish-speech", RecentModelFolder, ResultList.SelectedItem.ToString(), FishHome);
    

    }

  2. Assistant

    To implement the requested functionality, you want to:

    1. Check if there are any folders inside the checkpoints directory.
    2. Find the most recent folder inside checkpoints.
    3. Prompt the user with a warning asking if it is okay to override (delete) the contents of that most recent checkpoint folder.
    4. If the user accepts, delete all contents in that most recent folder except any folder named "fish-speech-1.5" (assuming it is inside that most recent folder).
    5. Then continue with the call to MergeLora.

    Here's an example implementation based on your comments and requirements:

    private void button4_Click(object sender, EventArgs e)
    {
        string FishHome = @"C:\AI\fish-speech";
        string ResultsHome = Path.Combine(FishHome, "results");
        string RecentModelFolder = PrintMostRecentFolderName(ResultsHome);
        string Checkpoints = Path.Combine(ResultsHome, RecentModelFolder, "checkpoints");
    
        // 1. Check if checkpoints directory exists and has folders
        if (!Directory.Exists(Checkpoints))
        {
            MessageBox.Show("Checkpoints directory does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;
        }
    
        string mostRecentCheckpointFolder = PrintMostRecentFolderName(Checkpoints);
    
        if (string.IsNullOrEmpty(mostRecentCheckpointFolder))
        {
            // No checkpoints to override, proceed without prompt
            MergeLora("fish-speech", RecentModelFolder, ResultList.SelectedItem.ToString(), FishHome);
            return;
        }
    
        // 2. Ask user confirmation to override
        DialogResult dr = MessageBox.Show(
            $"There is an existing checkpoint folder: {mostRecentCheckpointFolder} inside checkpoints.\n" +
            "Do you want to delete its contents (except 'fish-speech-1.5') and override?",
            "Confirm Override",
            MessageBoxButtons.YesNo,
            MessageBoxIcon.Warning);
    
        if (dr == DialogResult.Yes)
        {
            string folderToDelete = Path.Combine(Checkpoints, mostRecentCheckpointFolder);
    
            try
            {
                // 3. Delete all contents inside that checkpoint folder except the 'fish-speech-1.5' folder
                foreach (var dir in Directory.GetDirectories(folderToDelete))
                {
                    string dirName = Path.GetFileName(dir);
                    if (!string.Equals(dirName, "fish-speech-1.5", StringComparison.OrdinalIgnoreCase))
                    {
                        Directory.Delete(dir, true);
                    }
                }
    
                foreach (var file in Directory.GetFiles(folderToDelete))
                {
                    File.Delete(file);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error deleting checkpoint contents: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
        else
        {
            // User does not want to override. Exit or return.
            return;
        }
    
        MergeLora("fish-speech", RecentModelFolder, ResultList.SelectedItem.ToString(), FishHome);
    }
    

    Notes:

    • PrintMostRecentFolderName(string path) is assumed to return the most recent subfolder name inside the given path, or empty/null if none.
    • We prevent deleting the "fish-speech-1.5" folder but delete everything else inside the checkpoint folder.
    • If the checkpoints folder doesn't exist or there are no folders inside, the code proceeds without asking.
    • On any error during deletion, the process stops and shows an error message.
    • Ensure you have proper permissions for file/folder deletion.

    If you want, I can also help implement PrintMostRecentFolderName if you don't already have it.