Эх сурвалжийг харах

Fixed smbfs filename issue on share interface

Toby Chui 3 жил өмнө
parent
commit
b4a6d6b5e2
1 өөрчлөгдсөн 11 нэмэгдсэн , 11 устгасан
  1. 11 11
      mod/share/share.go

+ 11 - 11
mod/share/share.go

@@ -118,7 +118,7 @@ func (s *Manager) HandleOPGServing(w http.ResponseWriter, r *http.Request, share
 	ctx.SetSrc(image.NewUniform(color.RGBA{255, 255, 255, 255}))
 
 	//Check if we need to split the filename into two lines
-	filename := filepath.Base(shareEntry.FileRealPath)
+	filename := arozfs.Base(shareEntry.FileRealPath)
 	filenameOnly := strings.TrimSuffix(filename, filepath.Ext(filename))
 
 	fs := filesystem.GetFileSize(shareEntry.FileRealPath)
@@ -522,7 +522,7 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 					}
 
 					//Serve the target file
-					w.Header().Set("Content-Disposition", "attachment; filename*=UTF-8''"+strings.ReplaceAll(url.QueryEscape(filepath.Base(targetFilepath)), "+", "%20"))
+					w.Header().Set("Content-Disposition", "attachment; filename*=UTF-8''"+strings.ReplaceAll(url.QueryEscape(arozfs.Base(targetFilepath)), "+", "%20"))
 					w.Header().Set("Content-Type", r.Header.Get("Content-Type"))
 					//http.ServeFile(w, r, targetFilepath)
 
@@ -553,7 +553,7 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 					tmpFolder := s.options.TmpFolder
 					tmpFolder = filepath.Join(tmpFolder, "share-cache")
 					os.MkdirAll(tmpFolder, 0755)
-					targetZipFilename := filepath.Join(tmpFolder, filepath.Base(fileRuntimeAbsPath)) + ".zip"
+					targetZipFilename := filepath.Join(tmpFolder, arozfs.Base(fileRuntimeAbsPath)) + ".zip"
 
 					//Check if the target fs require buffer
 					zippingSource := shareOption.FileRealPath
@@ -561,7 +561,7 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 					zippingSourceFsh := targetFsh
 					if targetFsh.RequireBuffer {
 						//Buffer all the required files for zipping
-						localBuff = filepath.Join(tmpFolder, uuid.NewV4().String(), filepath.Base(fileRuntimeAbsPath))
+						localBuff = filepath.Join(tmpFolder, uuid.NewV4().String(), arozfs.Base(fileRuntimeAbsPath))
 						os.MkdirAll(localBuff, 0755)
 
 						//Buffer all files into tmp folder
@@ -605,7 +605,7 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 					}
 
 					//Serve thje zip file
-					w.Header().Set("Content-Disposition", "attachment; filename*=UTF-8''"+strings.ReplaceAll(url.QueryEscape(filepath.Base(shareOption.FileRealPath)), "+", "%20")+".zip")
+					w.Header().Set("Content-Disposition", "attachment; filename*=UTF-8''"+strings.ReplaceAll(url.QueryEscape(arozfs.Base(shareOption.FileRealPath)), "+", "%20")+".zip")
 					w.Header().Set("Content-Type", r.Header.Get("Content-Type"))
 					http.ServeFile(w, r, targetZipFilename)
 
@@ -638,7 +638,7 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 						//If error skip this
 						return nil
 					}
-					if filepath.Base(file)[:1] != "." {
+					if arozfs.Base(file)[:1] != "." {
 						fileSize := targetFshAbs.GetFileSize(file)
 						if targetFshAbs.IsDir(file) {
 							fileSize, _ = targetFsh.GetDirctorySizeFromRealPath(file, false)
@@ -656,7 +656,7 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 						}
 
 						treeList[relDir] = append(treeList[relDir], File{
-							Filename: filepath.Base(file),
+							Filename: arozfs.Base(file),
 							RelPath:  filepath.ToSlash(relPath),
 							Filesize: filesystem.GetFileDisplaySize(fileSize, 2),
 							IsDir:    targetFshAbs.IsDir(file),
@@ -687,7 +687,7 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 					"filecount":    strconv.Itoa(fcount),
 					"modtime":      timeString,
 					"downloadurl":  "../../share/download/" + id,
-					"filename":     filepath.Base(fileRuntimeAbsPath),
+					"filename":     arozfs.Base(fileRuntimeAbsPath),
 					"reqtime":      strconv.Itoa(int(time.Now().Unix())),
 					"requri":       "//" + r.Host + r.URL.Path,
 					"opg_image":    "/share/opg/" + strconv.Itoa(int(time.Now().Unix())) + "/" + id,
@@ -704,7 +704,7 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 			contentType := mime.TypeByExtension(filepath.Ext(fileRuntimeAbsPath))
 			if directDownload {
 				//Serve the file directly
-				w.Header().Set("Content-Disposition", "attachment; filename=\""+filepath.Base(shareOption.FileVirtualPath)+"\"")
+				w.Header().Set("Content-Disposition", "attachment; filename=\""+arozfs.Base(shareOption.FileVirtualPath)+"\"")
 				w.Header().Set("Content-Type", contentType)
 				w.Header().Set("Content-Length", strconv.Itoa(int(targetFshAbs.GetFileSize(fileRuntimeAbsPath))))
 
@@ -817,9 +817,9 @@ func (s *Manager) HandleShareAccess(w http.ResponseWriter, r *http.Request) {
 					"ext":         displayExt,
 					"size":        filesystem.GetFileDisplaySize(fsize, 2),
 					"modtime":     timeString,
-					"downloadurl": "/share/download/" + id + "/" + filepath.Base(fileRuntimeAbsPath),
+					"downloadurl": "/share/download/" + id + "/" + arozfs.Base(fileRuntimeAbsPath),
 					"preview_url": "/share/preview/" + id + "/",
-					"filename":    filepath.Base(fileRuntimeAbsPath),
+					"filename":    arozfs.Base(fileRuntimeAbsPath),
 					"opg_image":   "/share/opg/" + strconv.Itoa(int(time.Now().Unix())) + "/" + id,
 					"reqtime":     strconv.Itoa(int(time.Now().Unix())),
 				})