Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuous hashing #250

Merged
merged 6 commits into from Jan 21, 2015
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

fs-storage: rm thunky

OS IO cache is way smarter than this stupid indefinite caching.
  • Loading branch information
astro committed Jan 21, 2015
commit 5a70596d842ba47f0bcdaf7c720c0f671e135862
@@ -9,7 +9,6 @@ var path = require('path')
var raf = require('random-access-file')
var rimraf = require('rimraf')
var Storage = require('./storage')
var thunky = require('thunky')

var TMP = fs.existsSync('/tmp') ? '/tmp' : os.tmpDir()
function noop () {}
@@ -47,7 +46,7 @@ function FSStorage (parsedTorrent, opts) {
var pieceLength = file.pieceLength
var filePath = path.join(self.path, file.path)

var openWrite = thunky(function (cb) {
var openWrite = function (cb) {
var fileDir = path.dirname(filePath)

mkdirp(fileDir, function (err) {
@@ -58,16 +57,16 @@ function FSStorage (parsedTorrent, opts) {
file.fd = fd
cb(null, fd)
})
})
}

var openRead = thunky(function (cb) {
var openRead = function (cb) {
// TODO: no need for fs.exists call, just try opening and handle error.
// fs.exists then open creates opportunity for race condition.
fs.exists(filePath, function (exists) {
if (exists) return openWrite(cb)
cb(self.nonExistentError)
})
})
}

file.pieces.forEach(function (piece) {
var index = piece.index
@@ -160,6 +159,7 @@ FSStorage.prototype._onPieceDone = function (piece) {
var writeToNextFile = function (err) {
if (err) return self.emit('error', err)
if (i >= end) {
delete piece.buffer
return cb()
}

@@ -63,7 +63,6 @@
"simple-get": "^1.0.0",
"simple-sha1": "^2.0.0",
"speedometer": "^0.1.2",
"thunky": "^0.1.0",
"torrent-discovery": "^2.0.1",
"ut_metadata": "^2.1.0",
"ut_pex": "^1.0.1",
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.