Skip to content

refactor: Remove Transfer v2 interface; replace with toTransferDB() extension - #311

Merged
LouisCAD merged 3 commits into
mainfrom
copilot/remove-transfer-interface
Jun 17, 2026
Merged

refactor: Remove Transfer v2 interface; replace with toTransferDB() extension#311
LouisCAD merged 3 commits into
mainfrom
copilot/remove-transfer-interface

Conversation

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

The Transfer interface in com.infomaniak.multiplatform_swisstransfer.common.interfaces.transfers.v2 was a shared abstraction over both TransferApi and TransferDB, coupling network and database models unnecessarily. It is removed in favour of a direct conversion extension function.

Changes

Deleted

  • STCommon/.../interfaces/transfers/v2/Transfer.kt

TransferApi / TransferDB

  • Both no longer implement Transfer; override keywords dropped
  • TransferDB loses the constructor(transfer: Transfer, ...) secondary constructor
  • TransferDB.files narrows from List<File> to List<FileDB>

New: TransferApi.toTransferDB() (STCore)

// STCore/.../mappers/TransferApiV2Ext.kt
internal fun TransferApi.toTransferDB(
    direction: TransferDirection,
    linkId: String?,
    userOwnerId: Long,
    password: String? = null,
    status: TransferStatus = TransferStatus.READY,
): TransferDB

Callers updated

  • UploadV2ManagerprepareTransfer() returns TransferApi; getPendingTransferIfAny() returns TransferDB?; both use toTransferDB() internally
  • TransferManager.addTransferV2() — uses toTransferDB() instead of the removed constructor

Tests adapted

  • DummyTransferForV2 — dummy objects are now TransferDB instances directly instead of anonymous Transfer implementations
  • TransfersTest.insertTransfer() — accepts TransferDB, overrides fields via .copy()
  • UploadTest — helper methods use DummyTransferForV2.transfer1.copy(...) directly

v1 transfers are untouched.

Copilot AI changed the title Remove Transfer v2 interface, add toTransferDB() extension function Remove Transfer v2 interface; replace with toTransferDB() extension Jun 17, 2026
Copilot AI requested a review from LouisCAD June 17, 2026 11:54
@LouisCAD
LouisCAD marked this pull request as ready for review June 17, 2026 12:24
Copilot AI review requested due to automatic review settings June 17, 2026 12:24
@LouisCAD LouisCAD changed the title Remove Transfer v2 interface; replace with toTransferDB() extension refactor: Remove Transfer v2 interface; replace with toTransferDB() extension Jun 17, 2026
@LouisCAD
LouisCAD force-pushed the copilot/remove-transfer-interface branch from 754506a to fbb0b9e Compare June 17, 2026 12:27
@LouisCAD
LouisCAD enabled auto-merge June 17, 2026 12:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 removes the v2 Transfer shared interface that previously coupled network (TransferApi) and database (TransferDB) models, and replaces it with a dedicated TransferApi.toTransferDB() mapper used by v2 upload/download managers.

Changes:

  • Remove Transfer v2 abstraction usage: TransferApi/TransferDB no longer implement it, and related constructors/usages are updated.
  • Introduce internal fun TransferApi.toTransferDB(...) in STCore and migrate v2 persistence call sites to it.
  • Update v2 database tests/datasets to work directly with TransferDB and the updated TransferDB.files typing (List<FileDB>).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/models/transfer/v2/TransferApi.kt Drops Transfer v2 interface implementation from the network model.
STDatabase/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/database/models/transfers/v2/TransferDB.kt Drops Transfer v2 interface implementation, removes constructor-from-Transfer, narrows files to List<FileDB>.
STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/mappers/TransferApiV2Ext.kt Adds TransferApi.toTransferDB() mapper extension.
STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/managers/UploadV2Manager.kt Updates v2 upload flow to persist via toTransferDB() and adjusts return types.
STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/managers/TransferManager.kt Updates v2 add-transfer flow to persist via toTransferDB().
STDatabase/src/commonTest/kotlin/com/infomaniak/multiplatform_swisstransfer/database/v2/dataset/DummyTransferForV2.kt Updates dummy v2 transfers to be TransferDB instances.
STDatabase/src/commonTest/kotlin/com/infomaniak/multiplatform_swisstransfer/database/v2/TransfersTest.kt Updates helpers/tests to accept and manipulate TransferDB directly.
STDatabase/src/commonTest/kotlin/com/infomaniak/multiplatform_swisstransfer/database/v2/UploadTest.kt Updates upload tests to build pending transfers via TransferDB.copy(...).

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

auto-merge was automatically disabled June 17, 2026 12:48

Head branch was pushed to by a user without write access

@sonarqubecloud

Copy link
Copy Markdown

@LouisCAD
LouisCAD merged commit 27bfc07 into main Jun 17, 2026
9 checks passed
@LouisCAD
LouisCAD deleted the copilot/remove-transfer-interface branch June 17, 2026 13:05
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.

4 participants