-
Notifications
You must be signed in to change notification settings - Fork 18
重构 AV 对象初始化、查询并记录 appKey、运行时向程序发送 appKey #96
Conversation
return; // 如果已有新格式的文件则不迁移 | ||
|
||
try { | ||
fs.mkdirSync(leancloudFolder); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最好是创建文件夹的时候就把权限设置成 0600
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leancloudFolder(~/.leancloud
)是我们之前讨论过的用来放配置文件的文件夹,但可能并不是所有文件都是私密的,所以没有对这个文件夹设置权限,下面 leancloudAppKeysFile 是会设置权限的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以认为里面的所有信息都只允许当前用户读取,这个工具是给开发者用,所以不太可能存在一个操作系统多个用户要访问同一份目录内的信息。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样的话文件夹应该是 700,否则当前用户 cat ~/.leancloud/app_keys
会提示没有权限
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对,文件夹是 700
@@ -535,32 +617,10 @@ exports.createNewProject = function(cb) { | |||
|
|||
console.log("正在创建项目 ..."); | |||
AV.initialize(appId, masterKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不初始化 AV 对象是不是也可以?我感觉我们初始化 AV 对象的地方有点乱,这样很容易 AV 对象状态不正常但是不知道是哪里弄的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
其他与项目有关的命令在 initMasterKey 中 AV.initialize. 这个 createNewProject 因为和已有的项目无关,所以要自己在拿到 masterKey 后初始化 AV, 这个逻辑也还是挺清楚的,为简单看了一下似乎后面并没有用到 AV,所以这里也可以删掉。比较乱的部分是 initAVOSCloudSDK, 似乎是为了兼容以前保存在 config/global.json
的 masterKey.
重构 AV 对象初始化、查询并记录 appKey、运行时向程序发送 appKey
migrateAvoscloudKeys
用于将原路径的原格式文件迁移到新路径的新格式,为了储存 appKey, 格式从{appId: masterKey}
改为了{appId: {appKey, masterKey}}
.