API: Prevent file imports/uploads if there is no free storage #4266

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-03-11 20:35:07 +01:00
parent 0e3c365cac
commit a66d3278ab
95 changed files with 474 additions and 326 deletions

View File

@@ -49,11 +49,19 @@ func StartImport(router *gin.RouterGroup) {
conf := get.Config()
// Abort in read-only mode and/or when the import feature is disabled.
if conf.ReadOnly() || !conf.Settings().Features.Import {
AbortFeatureDisabled(c)
return
}
// Abort if there is not enough free storage to import new files.
if conf.FilesQuotaReached() {
event.AuditErr([]string{ClientIP(c), "session %s", "import files", "insufficient storage"}, s.RefID)
Abort(c, http.StatusInsufficientStorage, i18n.ErrInsufficientStorage)
return
}
start := time.Now()
var frm form.ImportOptions