Skip to content
This repository has been archived by the owner on Dec 20, 2017. It is now read-only.

重构 AV 对象初始化、查询并记录 appKey、运行时向程序发送 appKey #96

Merged
merged 7 commits into from
Oct 22, 2015
Merged

Conversation

jysperm
Copy link
Contributor

@jysperm jysperm commented Oct 14, 2015

migrateAvoscloudKeys 用于将原路径的原格式文件迁移到新路径的新格式,为了储存 appKey, 格式从 {appId: masterKey} 改为了 {appId: {appKey, masterKey}}.

@jysperm jysperm changed the title [WIP] 查询并记录 appKey 查询并记录 appKey, 运行时向程序发送真正的 appKey Oct 14, 2015
return; // 如果已有新格式的文件则不迁移

try {
fs.mkdirSync(leancloudFolder);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最好是创建文件夹的时候就把权限设置成 0600

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leancloudFolder(~/.leancloud)是我们之前讨论过的用来放配置文件的文件夹,但可能并不是所有文件都是私密的,所以没有对这个文件夹设置权限,下面 leancloudAppKeysFile 是会设置权限的。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以认为里面的所有信息都只允许当前用户读取,这个工具是给开发者用,所以不太可能存在一个操作系统多个用户要访问同一份目录内的信息。

Copy link
Contributor Author

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 会提示没有权限

Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不初始化 AV 对象是不是也可以?我感觉我们初始化 AV 对象的地方有点乱,这样很容易 AV 对象状态不正常但是不知道是哪里弄的。

Copy link
Contributor Author

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.

@jysperm jysperm changed the title 查询并记录 appKey, 运行时向程序发送真正的 appKey 重构 AV 对象初始化、查询并记录 appKey、运行时向程序发送 appKey Oct 19, 2015
sdjcw added a commit that referenced this pull request Oct 22, 2015
重构 AV 对象初始化、查询并记录 appKey、运行时向程序发送 appKey
@sdjcw sdjcw merged commit 9592906 into leancloud:master Oct 22, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants