@@ -226,7 +226,7 @@ const convertStoragePath = (
226226 case 'rclone' :
227227 return (
228228 ( noStorageName ? '' : storageName + ':' ) +
229- ( onlyStorageName ? '' : path ? formatPathRclone ( path , isDir ) : '' )
229+ ( onlyStorageName ? '' : path ? formatPathRclone ( path ) : '' )
230230 )
231231 case 'openlist' : {
232232 // 修复双斜杠问题:确保 path 不以 / 开头再拼接
@@ -236,7 +236,7 @@ const convertStoragePath = (
236236 ( onlyStorageName
237237 ? ''
238238 : normalizedPath
239- ? formatPathRclone ( storageName + '/' + normalizedPath , isDir )
239+ ? formatPathRclone ( storageName + '/' + normalizedPath )
240240 : storageName )
241241 )
242242 }
@@ -262,19 +262,14 @@ function getFileName(path: string): string {
262262 return pathArr [ pathArr . length - 1 ] ?? ''
263263}
264264
265- function formatPathRclone ( path : string , isDir ?: boolean ) : string {
265+ function formatPathRclone ( path : string ) : string {
266266 path = formatPath ( path )
267267 if ( path . startsWith ( '/' ) ) {
268268 path = path . substring ( 1 )
269269 }
270- if ( isDir ) {
271- if ( ! path . endsWith ( '/' ) ) {
272- path = path + '/'
273- }
274- } else {
275- if ( path . endsWith ( '/' ) ) {
276- path = path . substring ( 0 , path . length - 1 )
277- }
270+ // 始终移除末尾斜杠
271+ if ( path . endsWith ( '/' ) ) {
272+ path = path . substring ( 0 , path . length - 1 )
278273 }
279274 return path
280275}
@@ -284,9 +279,10 @@ async function getFileList(storageName: string, path: string): Promise<FileInfo[
284279 const storage = searchStorage ( storageName )
285280 let fileList : FileInfo [ ] | undefined = undefined
286281
282+ // 移除路径末尾的斜杠,根目录直接传空字符串
287283 const backData = await rclone_api_post ( '/operations/list' , {
288284 fs : convertStoragePath ( storageName , undefined , undefined , undefined , true ) ,
289- remote : convertStoragePath ( storageName , path , true , true ) ,
285+ remote : convertStoragePath ( storageName , path , false , true ) ,
290286 } )
291287
292288 if ( backData && backData . list ) {
@@ -295,7 +291,7 @@ async function getFileList(storageName: string, path: string): Promise<FileInfo[
295291 let filePath : string
296292
297293 if ( storage ?. framework === 'rclone' ) {
298- filePath = formatPathRclone ( file . Path , false )
294+ filePath = formatPathRclone ( file . Path )
299295 } else {
300296 // OpenList 存储:从 file.Path 中提取相对路径
301297 // file.Path 格式可能是: 百度网盘/视频/test.mp4 或 /百度网盘/视频/test.mp4
0 commit comments