fix: renaming caused the file to be displayed with wrong attributes
Massimo Melina committed
Jun 30, 2023 at 15:37 UTC
8c1e6659df2c0d98d3fbfe04ae958275eed562b9
2 files changed
+4
-2
frontend/src/fileMenu.ts
+1
-1
@@ -104,7 +104,7 @@ async function rename(entry: DirEntry) {
104
// update state instead of re-getting the list
105
const { n } = entry
106
const newN = n.replace(/(.*?)[^/]+(\/?)$/, (_,before,after) => before + dest + after)
107
- const newEntry = new DirEntry(newN)
107
+ const newEntry = new DirEntry(newN, entry)
108
const i = _.findIndex(state.list, { n })
109
state.list[i] = newEntry
110
const j = _.findIndex(state.filteredList, { n })
frontend/src/state.ts
+3
-1
@@ -80,6 +80,7 @@ function storeSettings() {
80
}
81
82
export class DirEntry {
83
+ public readonly n: string
84
public readonly s?: number
85
public readonly m?: string
86
public readonly c?: string
@@ -92,8 +93,9 @@ export class DirEntry {
93
public readonly t?:Date
94
public readonly cantOpen: boolean
95
95
- constructor(public readonly n: string, rest?: object) {
96
+ constructor(n: string, rest?: object) {
97
Object.assign(this, rest) // we actually allow any custom property to be memorized
98
+ this.n = n // must do it after rest to avoid overwriting
99
this.uri = pathEncode(this.n)
100
this.isFolder = this.n.endsWith('/')
101
if (!this.isFolder) {