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 /utils/file_backend_local.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 'utils/file_backend_local.go')
-rw-r--r-- | utils/file_backend_local.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/utils/file_backend_local.go b/utils/file_backend_local.go index ec0c657a7..681ab9234 100644 --- a/utils/file_backend_local.go +++ b/utils/file_backend_local.go @@ -49,6 +49,18 @@ func (b *LocalFileBackend) ReadFile(path string) ([]byte, *model.AppError) { } } +func (b *LocalFileBackend) FileExists(path string) (bool, *model.AppError) { + _, err := os.Stat(filepath.Join(b.directory, path)) + + if os.IsNotExist(err) { + return false, nil + } else if err == nil { + return true, nil + } + + return false, model.NewAppError("ReadFile", "api.file.file_exists.exists_local.app_error", nil, err.Error(), http.StatusInternalServerError) +} + func (b *LocalFileBackend) CopyFile(oldPath, newPath string) *model.AppError { if err := CopyFile(filepath.Join(b.directory, oldPath), filepath.Join(b.directory, newPath)); err != nil { return model.NewAppError("copyFile", "api.file.move_file.rename.app_error", nil, err.Error(), http.StatusInternalServerError) |