Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge 5fc8e29 into dfd5d5f
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloyan-raev committed Mar 8, 2018
2 parents dfd5d5f + 5fc8e29 commit e30aa08
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 41 deletions.
9 changes: 0 additions & 9 deletions lib/models/bucket.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const storj = require('storj-lib');
const mongoose = require('mongoose');
const SchemaOptions = require('../options');
const crypto = require('crypto');
Expand Down Expand Up @@ -88,14 +87,6 @@ Bucket.statics.create = function(user, data, callback) {
bucket.name = data.name;
}

// XXX THIS WILL BE DEPRECATED IN THE NEXT MAJOR RELEASE
// XXX Make sure to update any code that depends on this being
// XXX based on the name as soon as possible. Once this is
// XXX deprecated the id will be a unique ObjectId
bucket._id = mongoose.Types.ObjectId(
storj.utils.calculateBucketId(user._id, bucket.name)
);

bucket.save(function(err) {
if (err) {
if (err.code === 11000) {
Expand Down
11 changes: 0 additions & 11 deletions lib/models/bucketentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ const hmactypes = ['sha512', 'sha256', 'ripemd160'];
const erasuretypes = ['reedsolomon'];

function isValidIndex(index) {
// XXX DEPRECATION IN NEXT MAJOR RELEASE
// XXX The determinitic id will be deprecated and the index field will
// XXX become required for any new bucket entries. This is to make sure
// XXX that each bucket entry will have a unique id.
if (index) {
return index.length === 64 && utils.isHexaString(index);
}
Expand Down Expand Up @@ -112,14 +108,7 @@ BucketEntry.set('toObject', {
BucketEntry.statics.create = function(data, callback) {
var BucketEntry = this;

// XXX DEPRECATION IN NEXT MAJOR RELEASE
// XXX The determinitic id will be deprecated and the index field will
// XXX become required for any new bucket entries. This is to make sure
// XXX that each bucket entry will have a unique id.
const id = storj.utils.calculateFileId(data.bucket, data.name);

let doc = {
_id: id,
frame: data.frame,
bucket: data.bucket,
name: data.name
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "storj-service-storage-models",
"version": "10.6.0",
"version": "11.0.0",
"description": "common storage models for various storj services",
"main": "index.js",
"directories": {
Expand Down
8 changes: 0 additions & 8 deletions test/bucket.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ describe('Storage/models/Bucket', function() {

it('should create the bucket with the default props', function(done) {

// XXX DEPRECATED IN THE NEXT MAJOR RELEASE
var expectedBucketId =
storj.utils.calculateBucketId('user@domain.tld', 'New Bucket');

Bucket.create(
{ _id: 'user@domain.tld' },
{ name: 'New Bucket' },
Expand All @@ -51,10 +47,6 @@ describe('Storage/models/Bucket', function() {
expect(bucket.publicPermissions.length).to.equal(0);
Bucket.findOne({ _id: bucket.id }, function(err, bucket) {
expect(err).to.not.be.instanceOf(Error);

// XXX DEPRECATED IN THE NEXT MAJOR RELEASE
expect(bucket.id).to.equal(expectedBucketId);

expect(bucket.id.length).to.equal(24);
expect(bucket.name).to.equal('New Bucket');
expect(bucket.storage).to.equal(0);
Expand Down
15 changes: 3 additions & 12 deletions test/bucketentry.unit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const crypto = require('crypto');
const storj = require('storj-lib');
const expect = require('chai').expect;
const mongoose = require('mongoose');
const errors = require('storj-service-error-types');
Expand Down Expand Up @@ -41,17 +40,13 @@ after(function(done) {

describe('Storage/models/BucketEntry', function() {

var expectedBucketId =
storj.utils.calculateBucketId('user@domain.tld', 'New Bucket2');

// XXX DEPRECATED IN THE NEXT MAJOR RELEASE
var expectedFileId =
storj.utils.calculateFileId(expectedBucketId, 'test.txt');
var bucket2Id = null;

it('should create the bucket entry metadata', function(done) {
const index = crypto.randomBytes(32).toString('hex');
Bucket.create({ _id: 'user@domain.tld' }, { name: 'New Bucket2' },
function(err, bucket) {
bucket2Id = bucket._id;
var frame = new Frame({});
frame.save(function(err) {
expect(err).to.not.be.instanceOf(Error);
Expand All @@ -71,10 +66,6 @@ describe('Storage/models/BucketEntry', function() {
expect(entry.erasure.type).to.equal('reedsolomon');
expect(entry.index).to.equal(index);
expect(entry.filename).to.equal('test.txt');

// XXX DEPRECATED IN THE NEXT MAJOR RELEASE
expect(entry.id).to.equal(expectedFileId);

expect(entry.id.length).to.equal(24);
done();
});
Expand Down Expand Up @@ -113,7 +104,7 @@ describe('Storage/models/BucketEntry', function() {
BucketEntry.create({
index: crypto.randomBytes(32).toString('hex'),
frame: frame._id,
bucket: expectedBucketId,
bucket: bucket2Id,
name: 'test.txt',
mimetype: 'text/javascript'
}, function(err){
Expand Down

0 comments on commit e30aa08

Please sign in to comment.