mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
use fs.copyFile instead of fse.copy in UrlCache module
This commit is contained in:
parent
44e0742aa3
commit
371de76a4a
2 changed files with 3 additions and 6 deletions
|
@ -19,7 +19,6 @@ const UrlFetcher = require('./UrlFetcher')
|
||||||
const Settings = require('settings-sharelatex')
|
const Settings = require('settings-sharelatex')
|
||||||
const crypto = require('crypto')
|
const crypto = require('crypto')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const fse = require('fs-extra')
|
|
||||||
const logger = require('logger-sharelatex')
|
const logger = require('logger-sharelatex')
|
||||||
const async = require('async')
|
const async = require('async')
|
||||||
|
|
||||||
|
@ -36,7 +35,7 @@ module.exports = UrlCache = {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
return fse.copy(pathToCachedUrl, destPath, function (error) {
|
return fs.copyFile(pathToCachedUrl, destPath, function (error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
logger.error(
|
logger.error(
|
||||||
{ err: error, from: pathToCachedUrl, to: destPath },
|
{ err: error, from: pathToCachedUrl, to: destPath },
|
||||||
|
|
|
@ -27,8 +27,7 @@ describe('UrlCache', function () {
|
||||||
'settings-sharelatex': (this.Settings = {
|
'settings-sharelatex': (this.Settings = {
|
||||||
path: { clsiCacheDir: '/cache/dir' }
|
path: { clsiCacheDir: '/cache/dir' }
|
||||||
}),
|
}),
|
||||||
fs: (this.fs = {}),
|
fs: (this.fs = { copyFile: sinon.stub().yields() })
|
||||||
'fs-extra': (this.fse = { copy: sinon.stub().yields() })
|
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
@ -249,7 +248,6 @@ describe('UrlCache', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.cachePath = 'path/to/cached/url'
|
this.cachePath = 'path/to/cached/url'
|
||||||
this.destPath = 'path/to/destination'
|
this.destPath = 'path/to/destination'
|
||||||
this.UrlCache._copyFile = sinon.stub().callsArg(2)
|
|
||||||
this.UrlCache._ensureUrlIsInCache = sinon
|
this.UrlCache._ensureUrlIsInCache = sinon
|
||||||
.stub()
|
.stub()
|
||||||
.callsArgWith(3, null, this.cachePath)
|
.callsArgWith(3, null, this.cachePath)
|
||||||
|
@ -269,7 +267,7 @@ describe('UrlCache', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should copy the file to the new location', function () {
|
it('should copy the file to the new location', function () {
|
||||||
return this.fse.copy
|
return this.fs.copyFile
|
||||||
.calledWith(this.cachePath, this.destPath)
|
.calledWith(this.cachePath, this.destPath)
|
||||||
.should.equal(true)
|
.should.equal(true)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue