mm_os 2.6.5 → 2.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -172,9 +172,6 @@ MQTT.prototype.reconnect = function() {
172
172
  */
173
173
  MQTT.prototype.init = function(config) {
174
174
  this.config = Object.assign(this.config, config);
175
- this.client = {
176
- connected: false
177
- };
178
175
  this.retryTimes = 0;
179
176
  this.connecting = false;
180
177
  };
@@ -196,7 +193,7 @@ MQTT.prototype.start = function() {
196
193
  } else {
197
194
  this.client = MQTT_client.connect(cg);
198
195
  }
199
- if (this.client.on) {
196
+ if (this.client && this.client.on) {
200
197
  return new Promise((resolve, reject) => {
201
198
  this.client.on('connect', (packet, err) => {
202
199
  this.connecting = false;
@@ -334,7 +331,13 @@ MQTT.prototype.unsubscribe = function(topic, key) {
334
331
  * 结束客户端
335
332
  */
336
333
  MQTT.prototype.end = function() {
337
- this.client.end();
334
+ if (this.client) {
335
+ this.client.end();
336
+ }
337
+ if (this.timer) {
338
+ clearInterval(this.timer);
339
+ this.timer = null;
340
+ }
338
341
  };
339
342
 
340
343
  /**
@@ -112,7 +112,8 @@ Plugin.prototype.zip = async function(name) {
112
112
  * @returns {Boolean} 返回解压结果
113
113
  */
114
114
  Plugin.prototype.unzip = async function(file) {
115
- var dir = "/cache/plugin".fullname();
115
+ var name = file.basename().left(".");
116
+ var dir = `/cache/plugin/${name}`.fullname();
116
117
  dir.addDir();
117
118
  var ret;
118
119
  try {
@@ -183,11 +184,13 @@ Plugin.prototype.install = async function(file) {
183
184
  if (name) {
184
185
  var dir = `/app/${app}/plugin/${name}`;
185
186
  await this.copy_dir(dir_src, dir);
186
- dir_src.delDir();
187
187
  var cs = $.pool.plugin[app];
188
188
  if (cs) {
189
- await cs.update();
189
+ await cs.update(`/app/${app}/`.fullname());
190
190
  await cs.exec(name, 'install');
191
+ setTimeout(() => {
192
+ ret.dir.delDir();
193
+ }, 3000)
191
194
  }
192
195
  return {
193
196
  app,
@@ -201,6 +204,33 @@ Plugin.prototype.install = async function(file) {
201
204
  }
202
205
  }
203
206
 
207
+ // /**
208
+ // * 更新插件
209
+ // * @param {String} name 插件名称
210
+ // * @returns {Object} 返回更新结果
211
+ // */
212
+ // Plugin.prototype.update = async function(name) {
213
+ // var plus = this.get(name);
214
+ // if (plus) {
215
+ // var cg = plus.config;
216
+ // // 先将配置缓存
217
+ // var file = `/cache/config/${cg.app}_${cg.name}.json`;
218
+ // file.saveJson(cg);
219
+
220
+ // var dir = plus.filename.dirname();
221
+
222
+ // // 判断是否存在git仓库
223
+ // if (cg.git) {
224
+ // if (dir.hasDir('.git')) {
225
+ // // "git fetch";
226
+ // // "git reset --hard origin/master"
227
+ // }
228
+ // }
229
+ // } else {
230
+ // ret = $.ret.error("更新失败!原因:插件不存在");
231
+ // }
232
+ // }
233
+
204
234
  module.exports = Plugin;
205
235
 
206
236
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_os",
3
- "version": "2.6.5",
3
+ "version": "2.6.7",
4
4
  "description": "这是超级美眉服务端框架,用于快速构建应用程序。",
5
5
  "main": "index.js",
6
6
  "scripts": {