diff --git a/AppScope/app.json5 b/AppScope/app.json5 index 11868c13b2192dee75851b8c4352e3b81602cffe..a72902632a1dabd20b80e1cbda7b0fbcd735d373 100644 --- a/AppScope/app.json5 +++ b/AppScope/app.json5 @@ -3,7 +3,7 @@ "bundleName": "com.example.disklrucache", "vendor": "example", "versionCode": 1000000, - "versionName": "2.0.2-rc.0", + "versionName": "2.0.2-rc.3", "icon": "$media:app_icon", "label": "$string:app_name", "distributedNotificationEnabled": true diff --git a/CHANGELOG.md b/CHANGELOG.md index d1286940bf45292032813f1efb4f86e0442fc66c..56b6e714f1896121970824deb28b4d308a4a0fa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2.0.2-rc.3 +- 把废弃的@ohos/fileio变更为@ohos.file.fs + ## 2.0.2-rc.2 - 捕获判断文件夹接口异常导致应用闪退问题 diff --git a/README-en.md b/README-en.md index aac87e8d8e0c6307dcc150ddb538f13f688a25c8..aa7ac51125799d298a4eff32b488c09febdf9ca2 100644 --- a/README-en.md +++ b/README-en.md @@ -72,13 +72,13 @@ console.log(String.fromCharCode.aplly(null, new Uint8Array(data))); Cache a file synchronously. ```typescript -import fileio from '@ohos/fileio'; +import fs from '@ohos.file.fs'; let path = '/data/storage/el2/base/com.example.disklrucache/entry/files/testFile.txt'; -let fd = fileio.openSync(path, 0o2); -let length = fileio.statSync(path).size; +let fd = fs.openSync(path, 0o2); +let length = fs.statSync(path).size; let data = new ArrayBuffer(length); -fileio.readSync(fd, data); +fs.readSync(fd, data); this.testDiskLruCache.set('testFile', data); ``` @@ -104,19 +104,19 @@ this.testDiskLruCache.setAsync('test', value).then(() => { Cache a file asynchronously, and obtain a file from the cache asynchronously. ```typescript -import fileio from '@ohos/fileio'; +import fs from '@ohos.file.fs'; let path = '/data/storage/el2/base/com.example.disklrucache/entry/files/testFile.txt'; -let fd = fileio.openSync(path, 0o2); -let length = fileio.statSync(path).size; +let file = fs.openSync(path, 0o2); +let length = fs.statSync(path).size; let value = new ArrayBuffer(length); -fileio.readSync(fd, data); +fs.readSync(file.fd, data); this.testDiskLruCache.setAsync('test', value).then(() => { - this.testDiskLruCache.getAsync('test').then((data) => { - console.log(String.fromCharCode.aplly(null, new Uint8Array(data))); - }) + this.testDiskLruCache.getAsync('test').then((data) => { + console.log(String.fromCharCode.aplly(null, new Uint8Array(data))); + }) }).catch((err) => { - console.log('err =' + err); + console.log('err =' + err); }) ``` diff --git a/README.md b/README.md index ef14750f066f89791c524d6b087400de75cd2309..9c3abefd9323016ad10490b21275c77c4057a60f 100644 --- a/README.md +++ b/README.md @@ -72,13 +72,13 @@ console.log(String.fromCharCode.aplly(null, new Uint8Array(data))); 同步设置文件磁盘缓存数据。 ```typescript -import fileio from '@ohos/fileio'; +import fs from '@ohos.file.fs'; let path = '/data/storage/el2/base/com.example.disklrucache/entry/files/testFile.txt'; -let fd = fileio.openSync(path, 0o2); -let length = fileio.statSync(path).size; +let fd = fs.openSync(path, 0o2); +let length = fs.statSync(path).size; let data = new ArrayBuffer(length); -fileio.readSync(fd, data); +fs.readSync(fd, data); this.testDiskLruCache.set('testFile', data); ``` @@ -104,13 +104,13 @@ this.testDiskLruCache.setAsync('test', value).then(() => { 异步设置文件磁盘缓存数据和异步获取文件磁盘缓存数据。 ```typescript -import fileio from '@ohos/fileio'; +import fs from '@ohos.file.fs'; let path = '/data/storage/el2/base/com.example.disklrucache/entry/files/testFile.txt'; -let fd = fileio.openSync(path, 0o2); -let length = fileio.statSync(path).size; +let file = fs.openSync(path, 0o2); +let length = fs.statSync(path).size; let value = new ArrayBuffer(length); -fileio.readSync(fd, data); +fs.readSync(file.fd, data); this.testDiskLruCache.setAsync('test', value).then(() => { this.testDiskLruCache.getAsync('test').then((data) => { console.log(String.fromCharCode.aplly(null, new Uint8Array(data))); diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 index bdaf5b959471672ced8548bcd2dffc5aba53b165..232b130a0a06812df8c389448134aa65a6eb45f7 100644 --- a/entry/oh-package.json5 +++ b/entry/oh-package.json5 @@ -4,7 +4,7 @@ "name": "entry", "description": "example description", "repository": {}, - "version": "2.0.2-rc.2", + "version": "2.0.2-rc.3", "dependencies": { "@ohos/disklrucache": "file:../library" } diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 4edf057aff13a4659877de6d4887147ee3582784..6d4c2654c9e1d42b74481fcc779f089406dbc499 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -13,7 +13,7 @@ * limitations under the License. */ import { DiskLruCache } from '@ohos/disklrucache' -import fileio from '@ohos.fileio'; +import fs from '@ohos.file.fs'; import { GlobalContext } from "../entryability/GlobalContext" @@ -157,7 +157,7 @@ struct Index { this.testDiskLruCache.getFileToPathAsync(key).then((data) => { let index: number = data.lastIndexOf('/') let newPath: string = data.substring(0, index) + '/' + name + '.' + key - fileio.copyFileSync(data, newPath) + fs.copyFileSync(data, newPath) this.imageSrc = 'file://' + newPath }).catch((err: Error) => { this.imageSrc = undefined diff --git a/entry/src/ohosTest/ets/test/DiskLruCacheTest.test.ets b/entry/src/ohosTest/ets/test/DiskLruCacheTest.test.ets index 8c8da494e8c9264bb42ba37507af88836d1e18a4..47eb9a9f377a61dead3666ab20f681d026d1f412 100644 --- a/entry/src/ohosTest/ets/test/DiskLruCacheTest.test.ets +++ b/entry/src/ohosTest/ets/test/DiskLruCacheTest.test.ets @@ -15,7 +15,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' import { DiskLruCache, DiskCacheEntry } from '@ohos/disklrucache'; -import fileio from '@ohos.fileio'; +import fs from '@ohos.file.fs'; import { GlobalContext } from "../testability/GlobalContext" @@ -42,12 +42,12 @@ export default function DiskLruCacheTest() { let data = GlobalContext.getContext().getObject("filesDir") as string let cache: DiskLruCache = DiskLruCache.create(context); let path = data + '/testFile.txt'; - let fd = fileio.openSync(path, 0o102, 0o666); - fileio.writeSync(fd, "hello, world!"); - let length = fileio.statSync(path).size; - let dataarr = new ArrayBuffer(length); - fileio.readSync(fd, dataarr); - cache.set('testFile', dataarr); + let file = fs.openSync(path, 0o102); + fs.writeSync(file.fd, "hello, world!"); + let length = fs.statSync(path).size; + let dataArr = new ArrayBuffer(length); + fs.readSync(file.fd, dataArr); + cache.set('testFile', dataArr); expect(cache.get('testFile').byteLength == 13).assertTrue() cache.cleanCacheData(); }) diff --git a/entry/src/ohosTest/ets/test/TestInterfaceResponseTime.test.ets b/entry/src/ohosTest/ets/test/TestInterfaceResponseTime.test.ets index bd4a045e17fdd16cd521877458b17f393371cf51..6602471ab9110c57f84a05b7eb332cf1d1426090 100644 --- a/entry/src/ohosTest/ets/test/TestInterfaceResponseTime.test.ets +++ b/entry/src/ohosTest/ets/test/TestInterfaceResponseTime.test.ets @@ -21,7 +21,7 @@ export default function telephonyPerfJsunit(){ const BASE_COUNT=2000 const HTTP_COUNT=2 const BASELINE_HASSIMECASR=500 - const BASELINE_CREATEHTTP=500 + const BASELINE_CREATEHTTP=800 const BASELINE_REQUEST=2500 const BASELINE_DESTROY=30 diff --git a/library/oh-package.json5 b/library/oh-package.json5 index c9b888138f17c49d729e663340421dbf3748fdec..a28307eddf96a9e25e5b0bac60e0b6ea975f1eb7 100644 --- a/library/oh-package.json5 +++ b/library/oh-package.json5 @@ -13,7 +13,7 @@ "main": "index.ets", "repository": "https://gitee.com/openharmony-sig/ohos_disklrucache", "type": "module", - "version": "2.0.2-rc.2", + "version": "2.0.2-rc.3", "dependencies": {}, "tags": [ "Tool" diff --git a/library/src/main/ets/components/cache/DiskLruCache.ts b/library/src/main/ets/components/cache/DiskLruCache.ts index 71df48c951036efa53cdfb76b7b521cc13b2a99c..6ff2f05e711db8b4cfb21e101a2b7ad7f77d13d7 100644 --- a/library/src/main/ets/components/cache/DiskLruCache.ts +++ b/library/src/main/ets/components/cache/DiskLruCache.ts @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import fileio from '@ohos.fileio' +import fs from '@ohos.file.fs'; import { CustomMap } from './CustomMap' import { FileUtils } from './FileUtils' import { FileReader } from './FileReader' @@ -97,7 +97,7 @@ export class DiskLruCache { // 判断日志文件是否存在,如果没有初始化创建 if (FileUtils.getInstance().exist(journalPath)) { - let stat = fileio.statSync(journalPath) + let stat = fs.statSync(journalPath) if (stat.size > 0) { FileUtils.getInstance().createFile(journalPathTemp) FileUtils.getInstance().copyFile(journalPath, journalPathTemp) @@ -349,7 +349,7 @@ export class DiskLruCache { if (lineData.length > 1) { if (lineData[0] != DiskLruCache.REMOVE) { filePath = this.path + lineData[1] - let fileStat = fileio.statSync(filePath) + let fileStat = fs.statSync(filePath) if (fileStat.isFile() && fileStat.size > 0) { this.size = this.size + fileStat.size FileUtils.getInstance().writeData(this.journalPath, line + FileReader.LF) diff --git a/oh-package.json5 b/oh-package.json5 index 1c96bf052f95c0a857ac38adea99e2f36409ed42..fa9448b8ac1dbcca788239d6736d7338df37acf1 100644 --- a/oh-package.json5 +++ b/oh-package.json5 @@ -6,6 +6,6 @@ "name": "disklrucache", "description": "example description", "repository": {}, - "version": "2.0.2-rc.2", + "version": "2.0.2-rc.3", "dependencies": {} }