Skip to content

introduce CloudDisk API, enhance InstantUpload and Folder Manager, GUI refactors - #2

Open
moodyhunter wants to merge 16 commits into
mainfrom
clouddisk-api
Open

moodyhunter wants to merge 16 commits into
mainfrom
clouddisk-api

Conversation

@moodyhunter

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings July 3, 2026 17:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR is a large refactor/feature expansion that introduces a new Nextcloud “core” API surface (accounts, DB-backed sync folder mappings, transfer jobs, WebDAV helpers), adds a native CloudDisk/CloudSync N-API bridge for desktop-style sync, and updates the Entry UI/pages to use the new APIs (Instant Upload, settings, transfer progress, PC main page, status bar extension).

Changes:

  • Introduces DB-backed Account/Folder/SyncConfiguration models and a SyncEngine with TransferJob-based upload/download + IPC events.
  • Adds photo album based Instant Upload flows (PhotoAssetsManager/Category/PhotoItem) and refactors UI pages to consume them.
  • Adds native libcloudsync.so bindings + PC-oriented UI, background running, and new permissions/status bar extension.

Reviewed changes

Copilot reviewed 87 out of 92 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
watch_logs.cache.json Adds a cache file (currently empty array).
oh-package.json5 Bumps modelVersion; minor formatting tweaks.
oh-package-lock.json5 Fixes package name fields in lock entries.
nextcloud/src/main/module.json5 Adds READ_IMAGEVIDEO permission to the HAR module.
nextcloud/src/main/ets/webdav/Uploader.ets Removes old uploader implementation (replaced by TransferUtils/Jobs).
nextcloud/src/main/ets/webdav/TransferUtils.ets New WebDAV session/path utilities using Account + rcp.
nextcloud/src/main/ets/webdav/Files.ets Refactors listing to be Account-based + URL building changes.
nextcloud/src/main/ets/webdav/DirEntryParserStateMachine.ts Exports types/classes; logger import path update.
nextcloud/src/main/ets/Utils/Result.ets Adds Ok/Err/Result helpers.
nextcloud/src/main/ets/Utils/Logger.ts New Logger wrapper (component tagging + variadic messages).
nextcloud/src/main/ets/Utils/FilesDataSource.ets New FilesDataSource requiring Account.
nextcloud/src/main/ets/Utils/CommonUtils.ets Adds sleep/base64/time formatting utilities.
nextcloud/src/main/ets/Utils/BasicDatasource.ets Adds prepend/append/clear helpers for data sources.
nextcloud/src/main/ets/SyncEngine/TransferManagerEventIPC.ets Adds common-event IPC protocol for transfer manager events.
nextcloud/src/main/ets/SyncEngine/TransferManager.ets Adds a JobManager that tracks transfer jobs.
nextcloud/src/main/ets/SyncEngine/SyncFolderManager.ets Adds DB-backed sync folder/configuration manager.
nextcloud/src/main/ets/SyncEngine/PhotoItem.ets New PhotoItem model that creates UploadTransferJobs.
nextcloud/src/main/ets/SyncEngine/PhotoAssetsManager.ets Adds MediaLibrary-backed album/category discovery + monitoring integration.
nextcloud/src/main/ets/SyncEngine/Jobs/UploadTransferJob.ets Adds upload job with regular + chunked upload support.
nextcloud/src/main/ets/SyncEngine/Jobs/TransferJob.ets Adds transfer job base (progress tracking + event publishing).
nextcloud/src/main/ets/SyncEngine/Jobs/MkColJob.ets Adds placeholder job for MKCOL (currently no-op).
nextcloud/src/main/ets/SyncEngine/Jobs/Index.ets Exports jobs index.
nextcloud/src/main/ets/SyncEngine/Jobs/DownloadTransferJob.ets Adds download job using downloadToFile.
nextcloud/src/main/ets/SyncEngine/Jobs/BaseJob.ets Adds job lifecycle/state + listener support.
nextcloud/src/main/ets/SyncEngine/ImageListDataSource.ets Refactors to use local BasicDataSource + prepend support.
nextcloud/src/main/ets/SyncEngine/Category.ets New album-backed Category model with uploadAllAssets.
nextcloud/src/main/ets/Main.ets Adds Nextcloud singleton initialization + account migration.
nextcloud/src/main/ets/Logger.ts Removes old logger implementation.
nextcloud/src/main/ets/Index.ets Adds public barrel exports for the new API surface.
nextcloud/src/main/ets/FilesDataSource.ets Removes old FilesDataSource (moved to Utils).
nextcloud/src/main/ets/Database/Types/SyncConfiguration.ets Adds SyncConfiguration type wrapper.
nextcloud/src/main/ets/Database/Types/RemoteFolder.ets Adds RemoteFolder type wrapper.
nextcloud/src/main/ets/Database/Types/LocalFolder.ets Adds LocalFolder type wrapper.
nextcloud/src/main/ets/Database/Types/LocalAlbumFolder.ets Adds LocalAlbumFolder specialization.
nextcloud/src/main/ets/Database/DbTypes/DBSyncConfiguration.ets Adds DB schema/type for sync configurations.
nextcloud/src/main/ets/Database/DbTypes/DBRemoteFolder.ets Adds DB schema/type for remote folders.
nextcloud/src/main/ets/Database/DbTypes/DBLocalFolder.ets Adds DB schema/type for local folders + config JSON.
nextcloud/src/main/ets/Database/DbTypes/DBAccount.ets Adds DB schema/type for accounts + config JSON.
nextcloud/src/main/ets/Database/DBManager.ets Adds RDB management, schema creation, CRUD helpers.
nextcloud/src/main/ets/Common.ets Refactors preferences; removes category config from prefs; adds RandomString + pHelper.
nextcloud/src/main/ets/Account/LoginFlow.ets Refactors login flow into LoginFlow + Result usage; returns Account.
nextcloud/src/main/ets/Account/Account.ets Adds Account model (auth header + URL helpers + instant upload folder lookup).
nextcloud/oh-package.json5 Fixes package main entry path + formatting.
nextcloud/oh-package-lock.json5 Fixes lock package name fields.
nextcloud/index.ets Removes old top-level index.ets barrel.
hvigor/hvigor-config.json5 Bumps modelVersion; enables advanced analyze + typeCheck.
entry/src/main/resources/zh_CN/element/string.json Formatting-only change.
entry/src/main/resources/base/profile/main_pages.json Registers new pages (PC + status bar).
entry/src/main/resources/base/media/layered_image.json Formatting-only change.
entry/src/main/resources/base/element/string.json Formatting-only change.
entry/src/main/resources/base/element/float.json Adds a float resource (page_text_font_size).
entry/src/main/module.json5 Adds background/permissions + StatusBarAbility extension.
entry/src/main/ets/utils/Utils.ets Replaces time-path helpers with toast/dialog utilities using UIContext.
entry/src/main/ets/utils/PhotoMonitor.ets Adds MediaLibrary change monitoring + scheduling hooks.
entry/src/main/ets/utils/PermissionManager.ets Refactors permission requests to batch + UIContext handling.
entry/src/main/ets/utils/Path.ets Minor style update.
entry/src/main/ets/utils/NotificationManager.ets Adds notification helper for progress template.
entry/src/main/ets/utils/GlobalStorage.ets Refactors GlobalStorage into ObservedV2 singleton instance.
entry/src/main/ets/utils/DownloadQueue.ets Adds recursive download queue builder using ListFiles(Account,...).
entry/src/main/ets/utils/Common.ets Adds constants for account id + emitter event names.
entry/src/main/ets/utils/CloudSyncApi.ets Exposes libcloudsync.so functions + shared types.
entry/src/main/ets/statusbar/TransferStatusReceiver.ets Adds common-event subscriber to render transfer progress in status bar UI.
entry/src/main/ets/statusbar/StatusBarPage.ets Adds status bar page displaying transfer progress items.
entry/src/main/ets/statusbar/StatusBarAbility.ets Adds status bar extension ability to host StatusBarPage.
entry/src/main/ets/pages/UploadPage.ets Major UI refactor: album/category views + instant-upload folder creation + jobs.
entry/src/main/ets/pages/TransferProgress.ets Adds a transfer progress page listing JobManager tasks.
entry/src/main/ets/pages/SettingsPage.ets Refactors settings to per-account + toggle instant upload per album.
entry/src/main/ets/pages/PreviewPage.ets Refactors preview to use Account URL helpers and ComponentV2 patterns.
entry/src/main/ets/pages/PcMainPage.ets Adds PC main page: sync configurations + cloudsync callbacks + downloads + tabs.
entry/src/main/ets/pages/LoginPage.ets Refactors login UI to use LoginFlow returning Account + new dialogs/toasts.
entry/src/main/ets/pages/Index.ets Refactors main tabs, permissions, account selection, and adds Transfer tab.
entry/src/main/ets/pages/FolderPage.ets Refactors to Account-based listing/navigation + updated UI patterns.
entry/src/main/ets/models/PhotoItem.ets Removes old app-side PhotoItem model (moved to nextcloud module).
entry/src/main/ets/models/Category.ets Removes old app-side Category model (moved to nextcloud module).
entry/src/main/ets/entrybackupability/EntryBackupAbility.ets Removes backing up credentials (now DB-based; placeholder backup).
entry/src/main/ets/entryability/EntryAbility.ets Adds Nextcloud initialization, background running, tray/status bar integration.
entry/src/main/cpp/types/libcloudsync/oh-package.json5 Adds local types package descriptor for libcloudsync.
entry/src/main/cpp/types/libcloudsync/Index.d.ts Adds TS type definitions for native libcloudsync API.
entry/src/main/cpp/src/napi_init.cpp Implements N-API bindings to CloudDiskManager (register/connect/change callbacks).
entry/src/main/cpp/include/NapiUtils.hpp Adds typed N-API argument/value conversion helpers.
entry/src/main/cpp/include/NapiCallbackStorage.hpp Adds callback registry for JS callbacks.
entry/src/main/cpp/include/NapiCallback.hpp Adds threadsafe callback invocation wrapper.
entry/src/main/cpp/include/Logging.hpp Adds native logging macros.
entry/src/main/cpp/CMakeLists.txt Adds native build target linking CloudDiskManager + N-API libs.
entry/src/main/cpp/.vscode/settings.json Adds clangd compile_commands location for native dev.
entry/patch.json Bumps patchVersionCode.
entry/oh-package.json5 Adds local dependency on libcloudsync types package.
entry/oh-package-lock.json5 Updates lockfile for local deps + axios name field.
entry/build-profile.json5 Enables externalNativeOptions and native debugSymbol settings.
.gitignore Adds .bitfun/ ignore entry.
Comments suppressed due to low confidence (1)

nextcloud/src/main/ets/Account/LoginFlow.ets:33

  • initLogin() unconditionally prepends https:// to the provided hostname. The UI placeholder suggests users may enter a full URL (e.g. https://nextcloud.com), which would produce an invalid basePath like https://https://nextcloud.com. Normalize the input to a host (strip scheme and trailing slashes) before building URLs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +14 to +17
constructor() {
Logger.Info(TAG, `created TransferManager`);
this.tasks_ = new BasicDataSource<TransferJob>();
}
@Trace public transferredSize: number = 0;
@Trace public remoteFolder: RemoteFolder;
@Trace protected historicalBatchesTransferredSize: number = 0;
private readonly sessionExtraHeaders: Map<string, string> = new Map<string, string>();
Comment on lines +66 to +83
const timerId = setTimeout(() => {
publishTransferEvent({
code: TransferManagerEventCode.TASK_PROGRESS,
taskId: this.id,
transferredSize: this.transferredSize
})
}, 500);

try {
await this.onTransferWork(session);
session.close();
} catch (error) {
Logger.Error(this.TAG, `onTransferWork failed, error: ${JSON.stringify(error)}`);
session.close();
throw error as Error;
} finally {
clearTimeout(timerId);
}
Comment on lines +1 to +2
import { commonEventManager } from '@kit.BasicServicesKit';
import { Logger } from '../Index';
@@ -0,0 +1,76 @@
import { Logger } from '../../Index';
Comment on lines 10 to 18
"requestPermissions": [
{
"name": "ohos.permission.INTERNET"
},
{
"name": "ohos.permission.READ_IMAGEVIDEO",
"reason": "$string:page_show",
}
]
Comment thread watch_logs.cache.json
@@ -0,0 +1 @@
[] No newline at end of file
let page = this.isPc ? 'pages/PcMainPage' : 'pages/Index';
await this.startBackgroundRunning();
NCommon.pHelper = photoAccessHelper.getPhotoAccessHelper(this.context);
PhotoAssetsManager.initialize(Nextcloud.getSyncFolderManager().allLocalFolders);
Comment on lines +8 to +11
export interface UploadCallback {
jobCreated,
aboutToUpload,
}
export class PhotoItem {
@Trace uploadStatus: UploadStatus = UploadStatus.None;
private innerAsset: PHelper.PhotoAsset;
private uploadJob: Optional<UploadTransferJob> = undefined;
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.

2 participants