Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avfile missing data #35

Merged
merged 5 commits into from
Aug 11, 2017
Merged

Avfile missing data #35

merged 5 commits into from
Aug 11, 2017

Conversation

daweibayu
Copy link
Contributor

主要修复的问题:AVFile 与 HashMap 转换时部分字段丢失。
另外,AVFile 与 HashMap 转换的代码从 AVUtils 迁移到了 AVFile。

return new JSONObject(toHashMap());
}

public Map<String, Object> toHashMap() {
Copy link

Choose a reason for hiding this comment

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

函数名建议改成 toMap()

case StorageTypeS3:
file.setName((String) map.get(AVObject.OBJECT_ID));
break;
default:
Copy link

Choose a reason for hiding this comment

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

健壮性: 这里 switch 需要列举出所有 StorageType,然后 default 块抛出不支持此类型的异常,
即使是不需要的处理也要直接break
目的是防止日后新增类型之后没有因没有改动此处逻辑导致一些无法捕捉的事后 bug

// we store the objectId in file.name
result.put("id", getName());
break;
default:
Copy link

@zqq90 zqq90 Aug 11, 2017

Choose a reason for hiding this comment

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

同下,default 抛异常

* "51a306fce4b06e53feb1d95f", "updatedAt": "2013-05-27T07:10:52.000Z", "url":
* "https://s3-ap-northeast-1.amazonaws.com/avos-cloud/b60b1e29-5314-4538-9759-2cb6d6c74185" }
*/
public static Map<String, Object> mapFromFile(AVFile file) {
Copy link

Choose a reason for hiding this comment

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

建议保留方法,并标注@Deprecated,实现可以直接换成 file.toMap()

return result;
}

public static AVFile fileFromMap(Map<String, Object> map) {
Copy link

Choose a reason for hiding this comment

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

同上

@daweibayu daweibayu merged commit c364581 into leancloud:master Aug 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants