mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Cloud storage: fix sorting non-English filenames (#12644)
Reported in #12638.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
local DocumentRegistry = require("document/documentregistry")
|
||||
local JSON = require("json")
|
||||
local ffiUtil = require("ffi/util")
|
||||
local http = require("socket.http")
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
local logger = require("logger")
|
||||
@@ -7,7 +8,6 @@ local ltn12 = require("ltn12")
|
||||
local socket = require("socket")
|
||||
local socketutil = require("socketutil")
|
||||
local util = require("util")
|
||||
local BaseUtil = require("ffi/util")
|
||||
local _ = require("gettext")
|
||||
|
||||
local DropBoxApi = {
|
||||
@@ -126,7 +126,7 @@ function DropBoxApi:downloadFile(path, token, local_path)
|
||||
end
|
||||
|
||||
function DropBoxApi:uploadFile(path, token, file_path, etag, overwrite)
|
||||
local data = "{\"path\": \"" .. path .. "/" .. BaseUtil.basename(file_path) ..
|
||||
local data = "{\"path\": \"" .. path .. "/" .. ffiUtil.basename(file_path) ..
|
||||
"\",\"mode\":" .. (overwrite and "\"overwrite\"" or "\"add\"") ..
|
||||
",\"autorename\": " .. (overwrite and "false" or "true") ..
|
||||
",\"mute\": false,\"strict_conflict\": false}"
|
||||
@@ -202,10 +202,10 @@ function DropBoxApi:listFolder(path, token, folder_mode)
|
||||
end
|
||||
--sort
|
||||
table.sort(dropbox_list, function(v1,v2)
|
||||
return v1.text < v2.text
|
||||
return ffiUtil.strcoll(v1.text, v2.text)
|
||||
end)
|
||||
table.sort(dropbox_file, function(v1,v2)
|
||||
return v1.text < v2.text
|
||||
return ffiUtil.strcoll(v1.text, v2.text)
|
||||
end)
|
||||
-- Add special folder.
|
||||
if folder_mode then
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
local DocumentRegistry = require("document/documentregistry")
|
||||
local ffiUtil = require("ffi/util")
|
||||
local ftp = require("socket.ftp")
|
||||
local ltn12 = require("ltn12")
|
||||
local util = require("util")
|
||||
@@ -71,10 +72,10 @@ function FtpApi:listFolder(address_path, folder_path)
|
||||
end
|
||||
--sort
|
||||
table.sort(ftp_list, function(v1,v2)
|
||||
return v1.text < v2.text
|
||||
return ffiUtil.strcoll(v1.text, v2.text)
|
||||
end)
|
||||
table.sort(ftp_file, function(v1,v2)
|
||||
return v1.text < v2.text
|
||||
return ffiUtil.strcoll(v1.text, v2.text)
|
||||
end)
|
||||
for _, files in ipairs(ftp_file) do
|
||||
table.insert(ftp_list, {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local DocumentRegistry = require("document/documentregistry")
|
||||
local FFIUtil = require("ffi/util")
|
||||
local ffiUtil = require("ffi/util")
|
||||
local http = require("socket.http")
|
||||
local ltn12 = require("ltn12")
|
||||
local socket = require("socket")
|
||||
@@ -103,7 +103,7 @@ function WebDavApi:listFolder(address, user, pass, folder_path, folder_mode)
|
||||
--logger.dbg("WebDav catalog item=", item)
|
||||
-- <d:href> is the path and filename of the entry.
|
||||
local item_fullpath = item:match("<[^:]*:href[^>]*>(.*)</[^:]*:href>")
|
||||
local item_name = FFIUtil.basename(util.htmlEntitiesToUtf8(util.urlDecode(item_fullpath)))
|
||||
local item_name = ffiUtil.basename(util.htmlEntitiesToUtf8(util.urlDecode(item_fullpath)))
|
||||
local is_current_dir = item_name == string.sub(folder_path, -#item_name)
|
||||
local is_not_collection = item:find("<[^:]*:resourcetype%s*/>") or
|
||||
item:find("<[^:]*:resourcetype></[^:]*:resourcetype>")
|
||||
@@ -133,10 +133,10 @@ function WebDavApi:listFolder(address, user, pass, folder_path, folder_mode)
|
||||
|
||||
--sort
|
||||
table.sort(webdav_list, function(v1,v2)
|
||||
return v1.text < v2.text
|
||||
return ffiUtil.strcoll(v1.text, v2.text)
|
||||
end)
|
||||
table.sort(webdav_file, function(v1,v2)
|
||||
return v1.text < v2.text
|
||||
return ffiUtil.strcoll(v1.text, v2.text)
|
||||
end)
|
||||
for _, files in ipairs(webdav_file) do
|
||||
table.insert(webdav_list, {
|
||||
|
||||
Reference in New Issue
Block a user