Comparing version 1.3.4 to 1.4.0
17
index.js
@@ -9,2 +9,3 @@ 'use strict'; | ||
const md5 = require('nyks/crypto/md5'); | ||
const mkdirpSync = require('nyks/fs/mkdirpSync'); | ||
@@ -26,2 +27,18 @@ | ||
// return if index has been touched (new file) | ||
writeBuffer(file_name, body) { | ||
let file_md5 = md5(body); | ||
let file_path = this.store.getFilePathFromMd5(file_md5); | ||
let exists = this.checkEntry(file_name, file_md5); | ||
if(exists) | ||
return false; | ||
mkdirpSync(path.dirname(file_path)); | ||
let tmp = file_path + ".tmp"; | ||
fs.writeFileSync(tmp, body); | ||
fs.renameSync(tmp, file_path); | ||
return this._update(file_name, file_md5); | ||
} | ||
get(file_name) { | ||
@@ -28,0 +45,0 @@ if(!file_name) |
{ | ||
"name": "castor", | ||
"version": "1.3.4", | ||
"version": "1.4.0", | ||
"description": "An ES7 [CAS designed](https://en.wikipedia.org/wiki/Content-addressable_storage) file storage for nodejs with a simple API and robust implementation.", | ||
@@ -5,0 +5,0 @@ "main": "store.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15704
300