Selaa lähdekoodia

Fixed smb delete error

Toby Chui 3 vuotta sitten
vanhempi
commit
36ace42138
2 muutettua tiedostoa jossa 8 lisäystä ja 3 poistoa
  1. 2 1
      file_system.go
  2. 6 2
      mod/filesystem/abstractions/smbfs/smbfs.go

+ 2 - 1
file_system.go

@@ -1996,6 +1996,7 @@ func system_fs_handleOpr(w http.ResponseWriter, r *http.Request) {
 
 				err = srcFshAbs.RemoveAll(rsrcFile)
 				if err != nil {
+					systemWideLogger.PrintAndLog("File System", "Unable to remove file from "+srcFsh.UUID, err)
 					common.SendErrorResponse(w, err.Error())
 					return
 				}
@@ -2034,7 +2035,7 @@ func system_fs_handleOpr(w http.ResponseWriter, r *http.Request) {
 					if srcFsh.RequireBuffer {
 						common.SendErrorResponse(w, "Incompatible File System Type: Try SHIFT + DELETE to delete file permanently")
 					} else {
-						systemWideLogger.PrintAndLog("File System", "Failed to move file to trash: "+err.Error(), err)
+						systemWideLogger.PrintAndLog("File System", "Failed to move file to trash. See log for more info.", err)
 						common.SendErrorResponse(w, "Failed to move file to trash")
 					}
 					return

+ 6 - 2
mod/filesystem/abstractions/smbfs/smbfs.go

@@ -181,8 +181,12 @@ func (a ServerMessageBlockFileSystemAbstraction) RealPathToVirtualPath(fullpath
 
 func (a ServerMessageBlockFileSystemAbstraction) FileExists(realpath string) bool {
 	realpath = toWinPath(filterFilepath(realpath))
-	_, err := a.share.Open(realpath)
-	return err == nil
+	f, err := a.share.Open(realpath)
+	if err != nil {
+		return false
+	}
+	f.Close()
+	return true
 }
 
 func (a ServerMessageBlockFileSystemAbstraction) IsDir(realpath string) bool {