From d706fcaf67fd5249d57534a12c6d1ea2010c6871 Mon Sep 17 00:00:00 2001 From: Fouckttt Date: Sat, 19 Jul 2025 19:18:04 +0800 Subject: [PATCH] Overload Correction Issue:https://gitee.com/openharmony/interface_sdk-js/issues/ICNBV2 Signed-off-by: Fouckttt --- .../ets/@ohos.file.cloudSync.ets | 63 ++++++++++++------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/interfaces/kits/js/ani/file_cloud_sync/ets/@ohos.file.cloudSync.ets b/interfaces/kits/js/ani/file_cloud_sync/ets/@ohos.file.cloudSync.ets index b6d5227f5..9a204b687 100644 --- a/interfaces/kits/js/ani/file_cloud_sync/ets/@ohos.file.cloudSync.ets +++ b/interfaces/kits/js/ani/file_cloud_sync/ets/@ohos.file.cloudSync.ets @@ -71,11 +71,13 @@ export default namespace cloudSync { native on(evt: string, callback: GallerySyncCallback): void; - native off(evt: string, callback: GallerySyncCallback): void; + native offWithEvtCallback(evt: string, callback: GallerySyncCallback): void; - native off(evt: string): void; + native offWithEvt(evt: string): void; - start(): Promise { + overload off { offWithEvtCallback, offWithEvt } + + startReturnsPromise(): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((): int => this.StartInner()); @@ -87,7 +89,7 @@ export default namespace cloudSync { }); } - start(callback: AsyncCallback): void { + startWithCallback(callback: AsyncCallback): void { let promise = taskpool.execute((): int => this.StartInner()); promise.then((): void => { let e = new BusinessError(); @@ -98,7 +100,9 @@ export default namespace cloudSync { }); } - stop(): Promise { + overload start { startReturnsPromise, startWithCallback } + + stopReturnsPromise(): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((): int => this.StopInner()); @@ -110,7 +114,7 @@ export default namespace cloudSync { }); } - stop(callback: AsyncCallback): void { + stopWithCallback(callback: AsyncCallback): void { let promise = taskpool.execute((): int => this.StopInner()); promise.then((): void => { let e = new BusinessError(); @@ -121,6 +125,8 @@ export default namespace cloudSync { }); } + overload stop { stopReturnsPromise, stopWithCallback } + native GallerySyncStart(): void; native GallerySyncStop(): void; @@ -200,11 +206,13 @@ export default namespace cloudSync { native on(evt: string, callback: DownloadcCallback): void; - native off(evt: string, callback: DownloadcCallback): void; + native offWithEvtCallback(evt: string, callback: DownloadcCallback): void; - native off(evt: string): void; + native offWithEvt(evt: string): void; - start(uri: string): Promise { + overload off { offWithEvtCallback, offWithEvt } + + startWithUriReturnsPromise(uri: string): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((uri: string): int => this.StartInner(uri), uri); @@ -216,7 +224,7 @@ export default namespace cloudSync { }); } - start(uri: string, callback: AsyncCallback): void { + startWithUriCallback(uri: string, callback: AsyncCallback): void { let promise = taskpool.execute((uri: string): int => this.StartInner(uri), uri); promise.then((): void => { let e = new BusinessError(); @@ -227,7 +235,9 @@ export default namespace cloudSync { }); } - stop(uri: string): Promise { + overload start { startWithUriReturnsPromise, startWithUriCallback } + + stopWithUriReturnsPromise(uri: string): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((uri: string): int => this.StopInner(uri), uri); @@ -239,7 +249,7 @@ export default namespace cloudSync { }); } - stop(uri: string, callback: AsyncCallback): void { + stopWithUriCallback(uri: string, callback: AsyncCallback): void { let promise = taskpool.execute((uri: string): int => this.StopInner(uri), uri); promise.then((): void => { let e = new BusinessError(); @@ -250,6 +260,8 @@ export default namespace cloudSync { }); } + overload stop { stopWithUriReturnsPromise, stopWithUriCallback } + native DownloadStart(uri: string): void; native DownloadStop(uri: string): void; @@ -307,7 +319,8 @@ export default namespace cloudSync { } private nativePtr: long = 0; native constructor(); - native constructor(bundleName: string); + native constructorWithBundleName(bundleName: string); + overload constructor { constructorWithBundleName } bindNativePtr(ptr: long): void { if (this.nativePtr == 0) { @@ -333,7 +346,7 @@ export default namespace cloudSync { }); } - start(callback: AsyncCallback): void { + startWithCallback(callback: AsyncCallback): void { let promise = taskpool.execute((): int => this.StartInner()); promise.then((): void => { let e = new BusinessError(); @@ -344,7 +357,7 @@ export default namespace cloudSync { }); } - stop(): Promise { + startReturnsPromise(): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((): int => this.StopInner()); @@ -356,6 +369,8 @@ export default namespace cloudSync { }); } + overload start { startReturnsPromise, startWithCallback } + stop(callback: AsyncCallback): void { let promise = taskpool.execute((): int => this.StopInner()); promise.then((): void => { @@ -367,7 +382,7 @@ export default namespace cloudSync { }); } - getLastSyncTime(): Promise { + getLastSyncTimeReturnsPromise(): Promise { return new Promise((resolve: (result: number) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((): number => this.GallerySyncGetLastSyncTime()); @@ -379,7 +394,7 @@ export default namespace cloudSync { }); } - getLastSyncTime(callback: AsyncCallback): void { + getLastSyncTimeWithCallback(callback: AsyncCallback): void { let promise = taskpool.execute((): number => this.GallerySyncGetLastSyncTime()); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -391,6 +406,8 @@ export default namespace cloudSync { }); } + overload getLastSyncTime { getLastSyncTimeReturnsPromise, getLastSyncTimeWithCallback } + native FileSyncStart(): void; native FileSyncStop(): void; native GallerySyncGetLastSyncTime(): number; @@ -424,7 +441,7 @@ export default namespace cloudSync { native off(evt: string): void; - start(uri: string): Promise { + startWithUriReturnsPromise(uri: string): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((uri: string): int => this.StartInner(uri), uri); @@ -436,7 +453,7 @@ export default namespace cloudSync { }); } - start(uri: string, callback: AsyncCallback): void { + startWithUriCallback(uri: string, callback: AsyncCallback): void { let promise = taskpool.execute((uri: string): int => this.StartInner(uri), uri); promise.then((): void => { let e = new BusinessError(); @@ -447,7 +464,9 @@ export default namespace cloudSync { }); } - stop(uri: string, needClean?: boolean): Promise { + overload start { startWithUriReturnsPromise, startWithUriCallback } + + stopWithUriNeedCleanReturnsPromise(uri: string, needClean?: boolean): Promise { let clean: boolean = false; if (needClean !== undefined) { clean = needClean; @@ -465,7 +484,7 @@ export default namespace cloudSync { }); } - stop(uri: string, callback: AsyncCallback): void { + stopWithUriCallback(uri: string, callback: AsyncCallback): void { let clean: boolean = false; let promise = taskpool.execute((uri: string, clean: boolean): int => { return this.StopInner(uri, clean); @@ -479,6 +498,8 @@ export default namespace cloudSync { }); } + overload stop { stopWithUriNeedCleanReturnsPromise, stopWithUriCallback } + native CloudFileCacheStart(uri: string): void; native CloudFileCacheStop(uri: string, clean: boolean): void; native cleanCache(uri: string): void; -- Gitee