Skip to content

Commit 6895904

Browse files
committed
fix(node): cloning
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent 7c64dd5 commit 6895904

3 files changed

Lines changed: 7 additions & 13 deletions

File tree

lib/node/file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class File extends Node {
1515
* Returns a clone of the file
1616
*/
1717
clone(): File {
18-
return new File(this.data)
18+
return new File(this._data, this._knownDavService)
1919
}
2020

2121
}

lib/node/folder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import { Node } from './node'
88

99
export class Folder extends Node {
1010

11-
constructor(data: NodeData) {
11+
constructor(data: NodeData, davService?: RegExp) {
1212
// enforcing mimes
1313
super({
1414
...data,
1515
mime: 'httpd/unix-directory',
16-
})
16+
}, davService)
1717
}
1818

1919
get type(): FileType.Folder {
@@ -32,7 +32,7 @@ export class Folder extends Node {
3232
* Returns a clone of the folder
3333
*/
3434
clone(): Folder {
35-
return new Folder(this.data)
35+
return new Folder(this._data, this._knownDavService)
3636
}
3737

3838
}

lib/node/node.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ export enum NodeStatus {
2323

2424
export abstract class Node {
2525

26-
private _data: NodeData
2726
private _attributes: Attribute
28-
private _knownDavService = /(remote|public)\.php\/(web)?dav/i
27+
28+
protected _data: NodeData
29+
protected _knownDavService = /(remote|public)\.php\/(web)?dav/i
2930

3031
private readonlyAttributes = Object.entries(Object.getOwnPropertyDescriptors(Node.prototype))
3132
.filter(e => typeof e[1].get === 'function' && e[0] !== '__proto__')
@@ -346,13 +347,6 @@ export abstract class Node {
346347
this._data.status = status
347348
}
348349

349-
/**
350-
* Get the node data
351-
*/
352-
get data(): NodeData {
353-
return structuredClone(this._data)
354-
}
355-
356350
/**
357351
* Move the node to a new destination
358352
*

0 commit comments

Comments
 (0)