forked from amkovkov/GranuSightSoftware2
fix: ImageStorage.GetFullPath
This commit is contained in:
@@ -65,6 +65,14 @@ public class ImageStorageService
|
|||||||
|
|
||||||
File.Delete(fullPath);
|
File.Delete(fullPath);
|
||||||
_logger.LogInformation("File removed: {}", fileName);
|
_logger.LogInformation("File removed: {}", fileName);
|
||||||
|
|
||||||
|
var parentDirectory = Directory.GetParent(fullPath);
|
||||||
|
if (parentDirectory?.GetFiles().Count() == 0)
|
||||||
|
{
|
||||||
|
parentDirectory.Delete();
|
||||||
|
_logger.LogInformation("Empty directory removed: {}", parentDirectory.Name);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +91,7 @@ public class ImageStorageService
|
|||||||
return Path.Combine(_rootDirectory.FullName, subDirectory, level1, level2, fileName);
|
return Path.Combine(_rootDirectory.FullName, subDirectory, level1, level2, fileName);
|
||||||
|
|
||||||
return ListFiles()
|
return ListFiles()
|
||||||
.FirstOrDefault(File.Exists);
|
.FirstOrDefault(f => Path.GetFileName(f) == fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<string> ListFiles(string? subDirectory = null)
|
public List<string> ListFiles(string? subDirectory = null)
|
||||||
|
|||||||
Reference in New Issue
Block a user