Просмотр исходного кода

Merge pull request #44 from crowi/wip-v1.3.1

v1.3.1
Sotaro KARASAWA 10 лет назад
Родитель
Сommit
16b7b3c64d
3 измененных файлов с 33 добавлено и 33 удалено
  1. 7 0
      CHANGES.md
  2. 23 31
      lib/routes/me.js
  3. 3 2
      package.json

+ 7 - 0
CHANGES.md

@@ -1,6 +1,13 @@
 CHANGES
 ========
 
+## 1.3.1
+
+* Fix: Logic of checking uploadable was broken.
+* Fix: Creatable page name (Thank you: @riaf #42, Reported #33).
+* Fix: Warning on uploading with create page.
+* Fix: Error on uploading user profile image.
+
 ## 1.3.0
 
 * Feature: Image uploader.

+ 23 - 31
lib/routes/me.js

@@ -46,41 +46,33 @@ module.exports = function(crowi, app) {
     //  'url': imageUrl,
     //  'message': '',
     //});
+    var tmpFileStream = fs.createReadStream(tmpPath, {flags: 'r', encoding: null, fd: null, mode: '0666', autoClose: true });
+
+    fileUploader.uploadFile(filePath, tmpFile.mimetype, tmpFileStream, {})
+    .then(function(data) {
+      var imageUrl = fileUploader.generateS3FileUrl(filePath);
+      req.user.updateImage(imageUrl, function(err, data) {
+        fs.unlink(tmpPath, function (err) {
+          // エラー自体は無視
+          if (err) {
+            debug('Error while deleting tmp file.', err);
+          }
 
-    fileUploader.uploadFile(
-      filePath,
-      tmpFile.mimetype,
-      fs.createReadStream(tmpPath, {
-        flags: 'r',
-        encoding: null,
-        fd: null,
-        mode: '0666',
-        autoClose: true
-      }),
-      {},
-      function(err, data) {
-        if (err) {
           return res.json({
-            'status': false,
-            'message': 'Error while uploading to ',
-          });
-        }
-        var imageUrl = fileUploader.generateS3FileUrl(filePath);
-        req.user.updateImage(imageUrl, function(err, data) {
-          fs.unlink(tmpPath, function (err) {
-            // エラー自体は無視
-            if (err) {
-              console.log('Error while deleting tmp file.');
-            }
-            return res.json({
-              'status': true,
-              'url': imageUrl,
-              'message': '',
-            });
+            'status': true,
+            'url': imageUrl,
+            'message': '',
           });
         });
-      }
-    );
+      });
+    }).catch(function (err) {
+      debug('Uploading error', err);
+
+      return res.json({
+        'status': false,
+        'message': 'Error while uploading to ',
+      });
+    });
   };
 
   actions.index = function(req, res) {

+ 3 - 2
package.json

@@ -1,6 +1,6 @@
 {
   "name": "crowi",
-  "version": "1.3.0",
+  "version": "1.3.1",
   "description": "The simple & powerful Wiki",
   "tags": [
     "wiki",
@@ -11,7 +11,8 @@
   "author": "Sotaro KARASAWA <sotaro.k@gmail.com>",
   "contributors": [
     "Keisuke SATO <riaf@me.com> (http://riaf.jp)",
-    "Shinya Yamaoka <contact@mail.libmacro.com>"
+    "Shinya Yamaoka <contact@mail.libmacro.com>",
+    "Norio Suzuki <norio.suzuki@gmail.com>"
   ],
   "config": {
     "blanket": {