Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
write(path, str, callback) {
var tags = str
.trim()
.split(" ")
.reduce((memo, val) => {
if (memo.indexOf(val) === -1) {
memo.push(val);
}
return memo;
}, []);
if (tags.length && tags[0] !== "") {
var plistBuf = bplist.create([tags]);
xattr.set(path, XATTR_KEY, plistBuf, callback);
} else {
xattr.remove(path, XATTR_KEY, callback);
}
var now = new Date();
fs.utimesSync(path, now, now); // update last access/update times
}
});
it('should return default object if writelist is invalid in old-format', (done) => {
xattr.set(fpath, FRUITMIX, JSON.stringify({
uuid: uuid_1,
owner: [uuid_2],
writelist: 'Alice',
readlist: [uuid_3]
}), err => {
if(err) return done(err)
readXstat(fpath, (err, xstat) => {
if(err) return done(err)
expect(isUUID(xstat.uuid)).to.be.true
expect(xstat.uuid).to.not.equal(uuid_1)
expect(xstat.isDirectory()).to.be.true
expect(xstat.writelist).to.be.an('undefined')
expect(xstat.readlist).to.be.an('undefined')
expect(xstat.abspath).to.deep.equal(fpath)
done()
})
fs.stat(picpath, (err, stats) => {
if(err) return done()
xattr.set(picpath, FRUITMIX, JSON.stringify({
uuid: uuid_1,
hash: hash_1,
htime: stats.mtime.getTime(),
magic: 'JPEG'
}), err => {
if(err) return done(err)
readXstat(picpath, (err, xstat) => {
if(err) return done(err)
xattr.get(picpath, FRUITMIX, (err, attr) => {
if(err) return done(err)
let attrObj = JSON.parse(attr)
expect(attrObj.htime).to.equal(stats.mtime.getTime())
expect(xstat.uuid).to.deep.equal(uuid_1)
expect(xstat.isFile()).to.be.true
expect(xstat.writelist).to.be.an('undefined')
fs.stat(filepath, (err, stats) => {
xattr.set(filepath, FRUITMIX, JSON.stringify({
uuid: uuid_1,
hash: hash_1,
htime: stats.mtime.getTime()
}), err => {
if(err) return done(err)
fs.writeFile(copypath, '', err => {
if(err) return done(err)
done()
})
})
})
})
util.callbackify(() => xattr.set(path, 'com.apple.FinderInfo', buf))(cb)
}