Merge branch 'share,favorite' of http://khuhub.khu.ac.kr/2020-1-CloudComputing/D…
…_Team_Khuloud into share,favorite
Showing
1 changed file
with
10 additions
and
9 deletions
| ... | @@ -152,9 +152,9 @@ router.post('/move', function(req, res, next) { | ... | @@ -152,9 +152,9 @@ router.post('/move', function(req, res, next) { |
| 152 | user_id = req.body.id; | 152 | user_id = req.body.id; |
| 153 | let cur = req.body.cur; | 153 | let cur = req.body.cur; |
| 154 | curPath = user_id + cur; | 154 | curPath = user_id + cur; |
| 155 | - let name = req.body.folder_name; | 155 | + let name = req.body.name; |
| 156 | let newPath = user_id + req.body.newPath; | 156 | let newPath = user_id + req.body.newPath; |
| 157 | - if (req.body.isfolder) { | 157 | + if (req.body.isfolder == 'true') { |
| 158 | let checkfolder = 'SELECT * FROM folders WHERE location = ? AND folder_name = ? AND user_id = ?;'; | 158 | let checkfolder = 'SELECT * FROM folders WHERE location = ? AND folder_name = ? AND user_id = ?;'; |
| 159 | connection.query(checkfolder, [cur, name, user_id], function(err1, rows, fields) { | 159 | connection.query(checkfolder, [cur, name, user_id], function(err1, rows, fields) { |
| 160 | console.log(rows); | 160 | console.log(rows); |
| ... | @@ -200,22 +200,22 @@ router.post('/move', function(req, res, next) { | ... | @@ -200,22 +200,22 @@ router.post('/move', function(req, res, next) { |
| 200 | } | 200 | } |
| 201 | }); | 201 | }); |
| 202 | } else { | 202 | } else { |
| 203 | - console.log("Does not exist"); | 203 | + console.log("Does not exist folder"); |
| 204 | res.status(304).send({ error: "Does not exist" }); | 204 | res.status(304).send({ error: "Does not exist" }); |
| 205 | } | 205 | } |
| 206 | }); | 206 | }); |
| 207 | } else { | 207 | } else { |
| 208 | - let checkfile = 'SELECT * FROM files WHERE location = ? AND file_name = ? AND user_id = ?'; | 208 | + let checkfile = 'SELECT * FROM files WHERE location = ? AND file_name = ? AND user_id = ?;'; |
| 209 | - connection.query(checkfile, [curPath, name, user_id], function(err1, rows, fields) { | 209 | + connection.query(checkfile, [cur, name, user_id], function(err1, rows, fields) { |
| 210 | if (rows.length != 0) { | 210 | if (rows.length != 0) { |
| 211 | let copy_params = { | 211 | let copy_params = { |
| 212 | Bucket: BUCKET_NAME, | 212 | Bucket: BUCKET_NAME, |
| 213 | - CopySource: BUCKET_NAME + '/drive/' + curPath + file, | 213 | + CopySource: BUCKET_NAME + '/drive/' + curPath + name, |
| 214 | - Key: 'drive/' + newPath + file | 214 | + Key: 'drive/' + newPath + name |
| 215 | }; | 215 | }; |
| 216 | let del_params = { | 216 | let del_params = { |
| 217 | Bucket: BUCKET_NAME, | 217 | Bucket: BUCKET_NAME, |
| 218 | - Key: 'drive/' + curPath + file | 218 | + Key: 'drive/' + curPath + name |
| 219 | }; | 219 | }; |
| 220 | s3.copyObject(copy_params, function(err, data) { | 220 | s3.copyObject(copy_params, function(err, data) { |
| 221 | if (err) { | 221 | if (err) { |
| ... | @@ -227,7 +227,7 @@ router.post('/move', function(req, res, next) { | ... | @@ -227,7 +227,7 @@ router.post('/move', function(req, res, next) { |
| 227 | console.log(err, data); | 227 | console.log(err, data); |
| 228 | res.status(304).send({ error: "delete error" }); | 228 | res.status(304).send({ error: "delete error" }); |
| 229 | } else { | 229 | } else { |
| 230 | - let values = [newPath, cur, name, user_id]; | 230 | + let values = [req.body.newPath, cur, name, user_id]; |
| 231 | let updatesql = 'UPDATE files SET location = ? WHERE location = ? AND file_name = ? AND user_id = ?;'; | 231 | let updatesql = 'UPDATE files SET location = ? WHERE location = ? AND file_name = ? AND user_id = ?;'; |
| 232 | connection.query(updatesql, values, function(err3, result, field) { | 232 | connection.query(updatesql, values, function(err3, result, field) { |
| 233 | if (err3) { | 233 | if (err3) { |
| ... | @@ -246,6 +246,7 @@ router.post('/move', function(req, res, next) { | ... | @@ -246,6 +246,7 @@ router.post('/move', function(req, res, next) { |
| 246 | } | 246 | } |
| 247 | }); | 247 | }); |
| 248 | } else { | 248 | } else { |
| 249 | + console.log("Does not exist file"); | ||
| 249 | res.status(304).send({ error: "Does not exist" }); | 250 | res.status(304).send({ error: "Does not exist" }); |
| 250 | } | 251 | } |
| 251 | }); | 252 | }); | ... | ... |
-
Please register or login to post a comment