Giter Club home page Giter Club logo

repairkit's Introduction

RepairKit

来自WCDB的SQLite修复工具,感谢WCDB这个优秀的开源库。

快速开始

准备工作

  1. RepairKit文件夹拖入你的工程
  2. Build SettingsOther Linker Flags中加入,-ObjC/-force_load/./RepairKit路径/sqlcipher.framework/sqlcipher这三项。
  3. 在需要调用的类中#import "WCRepairKitManage.h"

备份数据库元数据

传入数据库路径即可完成备份。

[[WCRepairKitManage shareManage] backupDBPath:repairDBPath];

在有备份的情况,修复工具才可以生效。在数据库内的数据发生变化时,元数据备份有可能会过期。因此建议在子线程定期对其备份。

元数据通常只有几 kb 大小,且属于读操作,可以与其他操作并发执行。因此备份不会对性能产生大的影响。

修复数据库

传入数据库路径即可完成备份。

[[WCRepairKitManage shareManage] recoveryDBPath:repairDBPath DBPageSize:4096];

它将尝试从已损坏的数据库中读出数据,并插入到新数据库中。

修复过程根据数据库的大小不同,需要一定的时间。建议在界面上提示等待,并在子线程进行修复。

对于可再生的数据,如可从服务端重新拉取的数据,直接将数据库删掉重建是更好的恢复手段。

加解密备份元数据文件

传入数据库路径和秘钥字符串即可完成加密备份。

[[WCRepairKitManage shareManage] backupDBPath:repairDBPath backupCipher:backupCipherStr];

解密恢复类似,只需多传入秘钥字符串即可。

[[WCRepairKitManage shareManage] recoveryDBPath:repairDBPath DBPageSize:4096 backupCipher:backupCipher];

来源

RepairKit来自WCDB,因不属于对外接口,所以我通过参考Sample内的实现,完成了这个Demo。

SQLite修复原理

微信 SQLite 数据库损坏恢复实践

微信 SQLite 数据库修复实践

微信移动端数据库组件WCDB系列(二) — 数据库修复三板斧

WCDB 损坏、备份、修复

联系我

有任何的疑问和问题直接开启一个Issues。 其他沟通事项可以给我发邮件[email protected]

repairkit's People

Contributors

yiios avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

repairkit's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.