#103: Remove WAV support (#105)

* #103: Adding checks to prevent .wav files from being uploaded:

* #103: Added method to create song and moving some code around

* #103: Fixed build issue

* tsk-103: Cleanup of temporary files

* tsk-103: Formatting changes

* tsk-103: Minor changes

* tsk-103: Fixing build issue

* tsk-103: Refactored enum

* CORE-23734: Refactoring

* tsk-103: Confirmed functionality is working

* Removed commented code

* Removed commented code
This commit was merged in pull request #105.
This commit is contained in:
KD
2025-02-16 17:24:50 -05:00
committed by GitHub
parent a89580ac70
commit fd3ce9f96a
33 changed files with 242 additions and 99 deletions
@@ -53,7 +53,7 @@ public class DirectoryManager : BaseManager
public static string GenerateDownloadFilename(int length, string extension, string title, bool? randomize)
{
if (randomize.HasValue && randomize.Value)
if (randomize.HasValue && randomize.Value)
{
return GenerateFilename(length) + extension;
}
@@ -100,13 +100,13 @@ public class DirectoryManager : BaseManager
var artistDirectory = ArtistDirectory();
if (IsDirectoryEmpty(albumDirectory))
{
Directory.Delete(albumDirectory);
Console.WriteLine($"directory {albumDirectory} deleted");
Directory.Delete(albumDirectory);
Console.WriteLine($"directory {albumDirectory} deleted");
}
if (IsDirectoryEmpty(artistDirectory))
{
Directory.Delete(artistDirectory);
Console.WriteLine($"directory {artistDirectory} deleted");
Directory.Delete(artistDirectory);
Console.WriteLine($"directory {artistDirectory} deleted");
}
}
catch (Exception ex)
@@ -116,6 +116,38 @@ public class DirectoryManager : BaseManager
}
}
public int DeleteEmptyDirectories(string? directory, int level)
{
var deleted = 0;
try
{
var curDir = directory;
for (var i = 0; i < level; i++)
{
if (!System.IO.Directory.Exists(curDir))
{
continue;
}
if (this.IsDirectoryEmpty(curDir))
{
System.IO.Directory.Delete(curDir);
deleted++;
}
curDir = System.IO.Directory.GetParent(curDir).ToString();
}
}
catch (Exception ex)
{
var exMsg = ex.Message;
Console.WriteLine($"An error occurred {exMsg}");
}
return deleted;
}
public void DeleteEmptyDirectories(Song song)
{
try
@@ -125,12 +157,12 @@ public class DirectoryManager : BaseManager
if (IsDirectoryEmpty(albumDirectory))
{
Directory.Delete(albumDirectory);
Directory.Delete(albumDirectory);
_logger.Info("Album directory deleted");
}
if (IsDirectoryEmpty(artistDirectory))
{
Directory.Delete(artistDirectory);
Directory.Delete(artistDirectory);
_logger.Info("Artist directory deleted");
}
}
@@ -187,7 +219,7 @@ public class DirectoryManager : BaseManager
private class DirEnt
{
public string? Pre { get; set;}
public string? Pre { get; set; }
public string? Path { get; set; }
public string? Post { get; set; }
}