This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 746
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from fengmk2/issue58-sync-button
Issue58 sync button
- Loading branch information
Showing
17 changed files
with
313 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/**! | ||
* cnpmjs.org - controllers/download.js | ||
* | ||
* Copyright(c) cnpmjs.org and other contributors. | ||
* MIT Licensed | ||
* | ||
* Authors: | ||
* dead_horse <[email protected]> (http://deadhorse.me) | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
var Log = require('../proxy/module_log'); | ||
var SyncModuleWorker = require('./sync_module_worker'); | ||
|
||
exports.sync = function (req, res, next) { | ||
var username = req.session.name || 'anonymous'; | ||
var name = req.params.name; | ||
SyncModuleWorker.sync(name, username, function (err, result) { | ||
if (err) { | ||
return next(err); | ||
} | ||
if (!result.ok) { | ||
return res.json(result.statusCode, result.pkg); | ||
} | ||
res.json(201, { | ||
ok: true, | ||
logId: result.logId | ||
}); | ||
}); | ||
}; | ||
|
||
exports.getSyncLog = function (req, res, next) { | ||
var logId = req.params.id; | ||
var name = req.params.name; | ||
var offset = Number(req.query.offset) || 0; | ||
Log.get(logId, function (err, row) { | ||
if (err || !row) { | ||
return next(err); | ||
} | ||
var log = row.log.trim(); | ||
if (offset > 0) { | ||
log = log.split('\n').slice(offset).join('\n'); | ||
} | ||
res.json(200, {ok: true, log: log}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.