Skip to content

Commit

Permalink
저장 또는 불러오기시에 오류 사항 있을시 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
kimorkim committed Jun 16, 2016
1 parent 553da5e commit 8830f88
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
11 changes: 9 additions & 2 deletions app/src/native_controll.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,11 @@ Entry.plugin = (function () {
list.props.mode = '0777';
// console.log('entry');
});
fs_writer.on('error', function (e) {
if($.isFunction(cb)){
cb(e);
}
});
fs_writer.on('end', function () {

if($.isFunction(cb)){
Expand Down Expand Up @@ -512,7 +517,9 @@ Entry.plugin = (function () {
list.props.mode = '0777';
});
fs_writer.on('error', function (e) {
console.log('error');
if($.isFunction(cb)) {
cb(data);
}
});
fs_writer.on('end', function () {
fs.readFile(path.resolve(_real_path, 'temp', 'project.json'), enc || 'utf8', function (err, data) {
Expand All @@ -521,7 +528,7 @@ Entry.plugin = (function () {
}

if($.isFunction(cb)) {
cb(data);
cb(null, data);
}
});
});
Expand Down
27 changes: 23 additions & 4 deletions app/src/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,17 @@ angular.module('workspace').controller("WorkspaceController",
storage.setItem('defaultPath', parser.dir);

try{
myProject.saveProject(filePath, function (project_name) {
myProject.saveProject(filePath, function (e, project_name) {
if(e) {
$scope.doPopupControl({
'type':'hide'
});
$scope.doPopupControl({
'type':'fail',
'msg': Lang.Workspace.saving_fail_msg
});
$scope.isNowSaving = false;
}
Entry.stateManager.addStamp();
myProject.isSaved = true;
myProject.isSavedPath = filePath;
Expand Down Expand Up @@ -456,7 +466,16 @@ angular.module('workspace').controller("WorkspaceController",
'type':'spinner',
'msg': Lang.Workspace.loading_msg
});
Entry.plugin.loadProject(filePath, function (data) {
Entry.plugin.loadProject(filePath, function (e, data) {
if(e) {
$scope.doPopupControl({
'type':'hide'
});
$scope.doPopupControl({
'type':'fail',
'msg': Lang.Workspace.saving_fail_msg
});
}
var jsonObj = JSON.parse(data);
jsonObj.path = filePath;

Expand Down Expand Up @@ -862,9 +881,9 @@ angular.module('workspace').controller("WorkspaceController",
var project = Entry.exportProject();
project.name = project_name;

Entry.plugin.saveProject(path, project, function () {
Entry.plugin.saveProject(path, project, function (e) {
if($.isFunction(cb)) {
cb(project_name);
cb(e, project_name);
};
});
};
Expand Down

0 comments on commit 8830f88

Please sign in to comment.