-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
194 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Jellyfin.Plugin.Bangumi.Archive; | ||
|
||
[ApiController] | ||
[Route("Plugins/Bangumi/Archive")] | ||
public class OAuthController(ArchiveData archive) | ||
: ControllerBase | ||
{ | ||
[HttpGet("Status")] | ||
[Authorize] | ||
public Dictionary<string, object?> Status() | ||
{ | ||
var totalSize = 0L; | ||
DateTime? lastModifyTime = null; | ||
|
||
var directory = new DirectoryInfo(archive.BasePath); | ||
foreach (var info in directory.GetFileSystemInfos("*", SearchOption.AllDirectories)) | ||
{ | ||
if (lastModifyTime == null) | ||
lastModifyTime = info.LastWriteTime; | ||
else if (info.LastWriteTime.CompareTo(lastModifyTime) > 0) | ||
lastModifyTime = info.LastWriteTime; | ||
if (info is FileInfo fileInfo) | ||
totalSize += fileInfo.Length; | ||
} | ||
|
||
return new Dictionary<string, object?> | ||
{ | ||
["path"] = archive.BasePath, | ||
["size"] = totalSize, | ||
["time"] = lastModifyTime | ||
}; | ||
} | ||
|
||
[HttpDelete("Store")] | ||
[Authorize] | ||
public bool Delete() | ||
{ | ||
Directory.Delete(archive.BasePath, true); | ||
Directory.CreateDirectory(archive.BasePath); | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters