Add support for extended attributes
This commit is contained in:
@@ -22,6 +22,12 @@ class Node extends Model {
|
||||
descriptor_type: { type: String, default: NodeDescriptorType.File },
|
||||
uploaded_file_id: String,
|
||||
|
||||
extended_attributes: [{
|
||||
name: String,
|
||||
value: String, // base64 encoded binary buffer value
|
||||
// There's position, but it's legacy for macOS, so going to exclude it for now.
|
||||
}],
|
||||
|
||||
deleted: { type: Boolean, default: false },
|
||||
root: { type: Boolean, default: false },
|
||||
}
|
||||
@@ -56,6 +62,8 @@ class Node extends Model {
|
||||
}
|
||||
|
||||
static async get_path(path, workspace = 'mainline') {
|
||||
if ( path === '/' ) return this.get_root()
|
||||
|
||||
const [pied_parent_path, pied_name] = this.path_parts(path)
|
||||
|
||||
const nodes = await this.find({
|
||||
@@ -142,6 +150,28 @@ class Node extends Model {
|
||||
return [...nodes, ...mainline_nodes].filter(x => !x.deleted)
|
||||
}
|
||||
|
||||
set_xattr(name, value) {
|
||||
this.guarantee_xattrs()
|
||||
this.remove_xattr(name)
|
||||
this.extended_attributes.push({ name, value })
|
||||
}
|
||||
|
||||
get_xattr(name) {
|
||||
this.guarantee_xattrs()
|
||||
return this.extended_attributes.find(attr => attr.name === name)
|
||||
}
|
||||
|
||||
remove_xattr(name) {
|
||||
this.guarantee_xattrs()
|
||||
this.extended_attributes = this.extended_attributes.filter(attr => attr.name !== name)
|
||||
}
|
||||
|
||||
guarantee_xattrs() {
|
||||
if ( !Array.isArray(this.extended_attributes) ) {
|
||||
this.extended_attributes = []
|
||||
}
|
||||
}
|
||||
|
||||
to_api() {
|
||||
return {
|
||||
pied_name: this.pied_name,
|
||||
|
||||
Reference in New Issue
Block a user