Browse Source

Make all operations async and use a sharable interface for local or remote filesystems. Also, tests.

try asyncing file read, and use readableStream so we can pipe the output as soon as possible

create package.json

debug

we need to pass end: false to response while we're combining streams, otherwise it'll end when the first close event moves through. also, create a seperate decryptor each time, although maybe it'll work if we pass end: false to it as well.

streamline operations a bit

trying to address potential memory leak

some cleanup

Update package.json

Use a more appropriate version number based on statements in docs and elsewhere.

async writes

don't trigger response.end before everything may be done. delegate to the pipe and iteration

update compress_blocks so it's all async

load fs when log is initially loaded, not on every invocation

only use async methods so we can constuct a common procedure for local or remote file systems, and modularize code for testing and sanity

start building out tests

replace test file with truncated file

truncate test mp3

update interface for file type analysis

create common hash method and move wave offset method into module for testing

switch to library hashing method and chai expectations

test for wav offsetting

switch to utility method for wav offset

include chai in dev dependencies

cleanup

add tests around loading and saving inodes

comment

tweaks

create lib methods for handling params and target urls, for test coverage and standardization

build out gcs operations

guard around undefined getMaxListeners

add expectations to inode tests

travis test config

don't use 'static' (reserved) and fix typos

rework params construction to handle un-prefixed content-type

include test for content type param

fix config require in gcs module

pass host from header to target_from_uri

returned the called gcs createReadStream, not a reference to it

make sure we trim the port from the hostname

we need to expose the updated chunk_size for later update of the incoming buffer. it'd be nice to do this in a more functional manner and not mutate the var
main
Marc Brakken 5 years ago
parent
commit
f808b42a93
  1. 3
      lib/inode.js
  2. 1
      lib/utils.js
  3. 9
      test/utils.js

3
lib/inode.js

@ -101,7 +101,8 @@ var Inode = {
}
if (analysis_result.type === "wave") {
block = block.slice(0, utils.wave_audio_offset(block, analysis_result));
chunk_size = utils.wave_audio_offset(block, analysis_result)
block = block.slice(0, chunk_size);
}
}

1
lib/utils.js

@ -220,6 +220,7 @@ module.exports.request_parameters = function request_parameters(accepted_params,
module.exports.target_from_url = function target_from_url(hostname, uri) {
var parsed = url.parse(uri);
var pathname = parsed.pathname;
hostname = hostname.split(":")[0];
if (pathname.substring(0,2) !== "/.") {
return "/" + hostname.split(".").reverse().join(".") + pathname;

9
test/utils.js

@ -192,6 +192,15 @@ describe("utils.js", function() {
expect(result).to.equal(TEST_PATH);
});
it("should ignore port", function() {
var host = "test.jsfs.com:1234";
var uri = "/path/to/file.json";
var result = utils.target_from_url(host, uri);
expect(result).to.be.a("string");
expect(result).to.equal(TEST_PATH);
});
});
describe("#request_parameters", function() {

Loading…
Cancel
Save