[MM-28423] Implement ImportDelete job (#16588)

* Implement ImportDelete job

* Add missing translation

* Improve logging

* Avoid deleting the file in case of errors
Этот коммит содержится в:
Claudio Costa
2021-01-25 10:40:30 +01:00
коммит произвёл GitHub
родитель b932e0fb25
Коммит 200a56fa5a
22 изменённых файлов: 401 добавлений и 4 удалений

Просмотреть файл

@@ -19,7 +19,7 @@ import (
)
const minFirstPartSize = 5 * 1024 * 1024 // 5MB
const incompleteUploadSuffix = ".tmp"
const IncompleteUploadSuffix = ".tmp"
func (a *App) runPluginsHook(info *model.FileInfo, file io.Reader) *model.AppError {
pluginsEnvironment := a.GetPluginsEnvironment()
@@ -111,7 +111,7 @@ func (a *App) CreateUploadSession(us *model.UploadSession) (*model.UploadSession
if us.Type == model.UploadTypeAttachment {
us.Path = now.Format("20060102") + "/teams/noteam/channels/" + us.ChannelId + "/users/" + us.UserId + "/" + us.Id + "/" + filepath.Base(us.Filename)
} else if us.Type == model.UploadTypeImport {
us.Path = *a.Config().ImportSettings.Directory + "/" + us.Id + "_" + filepath.Base(us.Filename)
us.Path = filepath.Clean(*a.Config().ImportSettings.Directory) + "/" + us.Id + "_" + filepath.Base(us.Filename)
}
if err := us.IsValid(); err != nil {
return nil, err
@@ -194,7 +194,7 @@ func (a *App) UploadData(us *model.UploadSession, rd io.Reader) (*model.FileInfo
uploadPath := us.Path
if us.Type == model.UploadTypeImport {
uploadPath += incompleteUploadSuffix
uploadPath += IncompleteUploadSuffix
}
// make sure it's not possible to upload more data than what is expected.