s3: fix storage limit rolloever

This commit is contained in:
Abdullah Atta
2025-11-05 22:42:45 +05:00
parent 1e8a205719
commit 54d0fdcf4f
4 changed files with 40 additions and 7 deletions

View File

@@ -52,6 +52,17 @@ namespace Notesnook.API.Helpers
return fileSize > maxFileSize;
}
public static Limit RolloverStorageLimit(Limit? limit)
{
var updatedAt = DateTimeOffset.FromUnixTimeMilliseconds(limit?.UpdatedAt ?? 0);
if (limit == null || DateTimeOffset.UtcNow.Year > updatedAt.Year || DateTimeOffset.UtcNow.Month > updatedAt.Month)
{
limit = new Limit { UpdatedAt = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), Value = 0 };
return limit;
}
return limit;
}
private static readonly string[] sizes = ["B", "KB", "MB", "GB", "TB"];
public static string FormatBytes(long size)
{