oldj 8 years ago
parent
commit
16f79de880
3 changed files with 11 additions and 3 deletions
  1. 1 1
      app/bundle.js
  2. 9 1
      app/server/io.js
  3. 1 1
      ui/app.js

+ 1 - 1
app/bundle.js

@@ -20953,7 +20953,7 @@ var App = function (_React$Component) {
         if (!list) return;
         _Agent2.default.emit('list_updated', list);
       });
-    }, 10000);
+    }, 3000);
     return _this;
   }
 

+ 9 - 1
app/server/io.js

@@ -7,6 +7,8 @@
 'use strict'
 
 const fs = require('fs')
+const crypto = require('crypto')
+const md5File = require('md5-file')
 
 exports.getUserHome = () => {
   return process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME']
@@ -33,7 +35,13 @@ exports.isDirectory = (p) => {
 }
 
 let writeFile = exports.writeFile = (fn, data, callback) => {
-  fs.writeFile(fn, data, 'utf-8', callback)
+  let cnt_md5 = crypto.createHash('md5').update(data).digest('hex')
+  if (isFile(fn) && md5File.sync(fn) === cnt_md5) {
+    callback()
+  } else {
+    console.log('md5 not match..')
+    fs.writeFile(fn, data, 'utf-8', callback)
+  }
 }
 
 exports.pWriteFile = (fn, data) => {

+ 1 - 1
ui/app.js

@@ -43,7 +43,7 @@ export default class App extends React.Component {
           if (!list) return
           Agent.emit('list_updated', list)
         })
-    }, 10000)
+    }, 3000)
   }
 
   loadHosts () {