diff options
author | Daniel Schalla <daniel@schalla.me> | 2018-06-25 18:12:59 +0200 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2018-06-25 12:12:59 -0400 |
commit | ecefa6cdd1e7376046bbec82c1b47f7756fea646 (patch) | |
tree | d1cb2486e344c1bb93353020713b9eb2146a5b6f /app/user.go | |
parent | fc158fce907b602bbde3babfadfd1a04d1dde31e (diff) | |
download | chat-ecefa6cdd1e7376046bbec82c1b47f7756fea646.tar.gz chat-ecefa6cdd1e7376046bbec82c1b47f7756fea646.tar.bz2 chat-ecefa6cdd1e7376046bbec82c1b47f7756fea646.zip |
Implementation of File Exists Function; Delete FileInfos upon Permanent User Delete (#8958)
Check if file was deleted on FS
Warning message if file couldnt be removed
Diffstat (limited to 'app/user.go')
-rw-r--r-- | app/user.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/user.go b/app/user.go index 27e6f347d..b00ef19ef 100644 --- a/app/user.go +++ b/app/user.go @@ -1288,6 +1288,33 @@ func (a *App) PermanentDeleteUser(user *model.User) *model.AppError { return result.Err } + fchan := a.Srv.Store.FileInfo().GetForUser(user.Id) + var infos []*model.FileInfo + if result := <-fchan; result.Err != nil { + mlog.Warn("Error getting file list for user from FileInfoStore") + } else { + infos = result.Data.([]*model.FileInfo) + for _, info := range infos { + res, err := a.FileExists(info.Path) + + if err != nil { + mlog.Warn(fmt.Sprintf("Error checking existence of file '%s': %s", info.Path, err)) + continue + } + + if res { + a.RemoveFile(info.Path) + } else { + mlog.Warn(fmt.Sprintf("Unable to remove file '%s': %s", info.Path, err)) + } + + } + } + + if result := <-a.Srv.Store.FileInfo().PermanentDeleteByUser(user.Id); result.Err != nil { + return result.Err + } + if result := <-a.Srv.Store.User().PermanentDelete(user.Id); result.Err != nil { return result.Err } |