瀏覽代碼

use fs.copyFile instead of fse.copy in UrlCache module

Brian Gough 5 年之前
父節點
當前提交
371de76a4a
共有 2 個文件被更改,包括 3 次插入 和 6 次删除
  1. 1 2
      services/clsi/app/js/UrlCache.js
  2. 2 4
      services/clsi/test/unit/js/UrlCacheTests.js

+ 1 - 2
services/clsi/app/js/UrlCache.js

@@ -19,7 +19,6 @@ const UrlFetcher = require('./UrlFetcher')
 const Settings = require('settings-sharelatex')
 const crypto = require('crypto')
 const fs = require('fs')
-const fse = require('fs-extra')
 const logger = require('logger-sharelatex')
 const async = require('async')
 
@@ -36,7 +35,7 @@ module.exports = UrlCache = {
         if (error != null) {
           return callback(error)
         }
-        return fse.copy(pathToCachedUrl, destPath, function (error) {
+        return fs.copyFile(pathToCachedUrl, destPath, function (error) {
           if (error != null) {
             logger.error(
               { err: error, from: pathToCachedUrl, to: destPath },

+ 2 - 4
services/clsi/test/unit/js/UrlCacheTests.js

@@ -27,8 +27,7 @@ describe('UrlCache', function () {
         'settings-sharelatex': (this.Settings = {
           path: { clsiCacheDir: '/cache/dir' }
         }),
-        fs: (this.fs = {}),
-        'fs-extra': (this.fse = { copy: sinon.stub().yields() })
+        fs: (this.fs = { copyFile: sinon.stub().yields() })
       }
     }))
   })
@@ -249,7 +248,6 @@ describe('UrlCache', function () {
     beforeEach(function () {
       this.cachePath = 'path/to/cached/url'
       this.destPath = 'path/to/destination'
-      this.UrlCache._copyFile = sinon.stub().callsArg(2)
       this.UrlCache._ensureUrlIsInCache = sinon
         .stub()
         .callsArgWith(3, null, this.cachePath)
@@ -269,7 +267,7 @@ describe('UrlCache', function () {
     })
 
     it('should copy the file to the new location', function () {
-      return this.fse.copy
+      return this.fs.copyFile
         .calledWith(this.cachePath, this.destPath)
         .should.equal(true)
     })