file: honor server's remote-root option (remove root path from displayed path and returned value)

This commit is contained in:
jean-emmanuel 2025-09-15 09:05:37 +02:00
parent 9ef97ca1c3
commit 4dbc572ea1
4 changed files with 17 additions and 7 deletions

View file

@ -40,6 +40,7 @@ export default function UiFilebrowser(options, callback) {
`
var files = [],
root = '',
path = ''
var extRe = options.extension ? new RegExp('.*\\.' + options.extension + '$') : /.*/
@ -75,10 +76,10 @@ export default function UiFilebrowser(options, callback) {
if (files.some(x=>x.name===saveInput.value)) {
if (!confirm(locales('remotesave_overwrite'))) return
}
callback([path, saveInput.value])
callback([path, saveInput.value], root)
popup.close()
} else {
callback([path, choice ? choice.value : ''])
callback([path, choice ? choice.value : ''], root)
popup.close()
}
}
@ -142,11 +143,13 @@ export default function UiFilebrowser(options, callback) {
ipc.on('listDir', (data)=>{
ariane.textContent = path = data.path
path = data.path
root = data.root
ariane.textContent = path.replace(root, '/')
files = data.files.filter(x=>x.folder || x.name.match(extRe))
function alphaSort(a, b){
// convert to strings and force lowercase
a = typeof a.name === 'string' ? a.name.toLowerCase() : a.name.toString()

View file

@ -58,9 +58,13 @@ export default class File extends Widget {
directory: this.getProp('directory') === 'auto' ? undefined : this.getProp('directory'),
loadDir: this.getProp('allowDir'),
save: this.getProp('mode') === 'save'
}, (path)=>{
}, (path, root)=>{
this.setValue(path.join(path[0][0] === '/' ? '/' : '\\'), {
var sep = path[0][0] === '/' ? '/' : '\\',
val = path.join(sep)
if (root) val = val.replace(root, sep).replace(sep + sep, sep)
this.setValue(val, {
sync: true,
send: true
})

View file

@ -567,7 +567,8 @@ export default class Callbacks {
list = list.filter(x=>x.folder || x.name.match(extRe))
this.ipcServer.send('listDir', {
path: p,
files: list
files: list,
root: root
}, clientId)
settings.write('last-dir', p, false, false)
}