Skip to content

Commit

Permalink
fix issue#497
Browse files Browse the repository at this point in the history
  • Loading branch information
jepiqueau committed Dec 29, 2023
1 parent 0473751 commit 548cd9a
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 5.5.1-3 (2023-12-29)

### Bug Fixes

- Android addSQLiteSuffix or moveDatabasesAndAddSuffix doesn't copy data inside the original database issue#497

# 5.5.1-2 (2023-12-21)

### Chore
Expand Down
Binary file modified android/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -796,10 +796,9 @@ public void getDatabaseList(PluginCall call) {
*/
@PluginMethod
public void getMigratableDbList(PluginCall call) {
String folderPath = null;
String folderPath;
if (!call.getData().has("folderPath")) {
String msg = "getMigratableDbList: Must provide a folder path";
rHandler.retValues(call, new JSArray(), msg);
folderPath = "default";
} else {
folderPath = call.getString("folderPath");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,13 @@ public Boolean copyFile(Context context, String dbName, String toDbName) {

public Boolean copyFromNames(Context context, String fromPath, String fromName, String toPath, String toName) {
File fromFile = new File(fromPath, fromName);
boolean fFile = fromFile.setReadable(true, false);
/*
boolean fFile = fromFile.setReadable(true, false);
if (!fFile) {
Log.e(TAG, "Error: in fromFile " + fromName);
return false;
}
*/
File toFile = context.getDatabasePath(toName);
try {
if (!toFile.exists()) {
Expand Down
2 changes: 1 addition & 1 deletion docs/APIConnection.md
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ Get the database list
### getMigratableDbList(...)

```typescript
getMigratableDbList(folderPath: string) => Promise<capSQLiteValues>
getMigratableDbList(folderPath?: string | undefined) => Promise<capSQLiteValues>
```

Get the Migratable database list
Expand Down
1 change: 0 additions & 1 deletion docs/MigratingCordovaDatabases.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ this will copy all the databases from the "default" folder and add to them the S

- on iOS the "default" location is `Documents` under the application
- on Android the "default" location is `databases` under the application
- on Electron the "default" location is `Databases/YOUR_APPLICATION_NAME`in the Home directory

If you were using a custom location you have to give the location as parameter, only few custom locations are accessibles depending on the platform.

Expand Down
10 changes: 2 additions & 8 deletions ios/Plugin/CapacitorSQLitePlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -700,16 +700,10 @@ public class CapacitorSQLitePlugin: CAPPlugin {
// MARK: - getMigratableDbList

@objc func getMigratableDbList(_ call: CAPPluginCall) {
guard let dbFolder = call.options["folderPath"] as? String else {
retHandler.rValues(
call: call, ret: [],
message: "getMigratableDbList: Must provide a folder path")
return
}

let folderPath: String = call.getString("folderPath") ?? "default"
do {
let res = try implementation?
.getMigratableDbList(dbFolder) ?? []
.getMigratableDbList(folderPath) ?? []
retHandler.rValues(call: call, ret: res)
return
} catch CapacitorSQLiteError.failed(let message) {
Expand Down
10 changes: 4 additions & 6 deletions src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ export interface ISQLiteConnection {
* @returns Promise<capSQLiteValues>
* @since 3.0.0-beta.5
*/
getMigratableDbList(folderPath: string): Promise<capSQLiteValues>;
getMigratableDbList(folderPath?: string): Promise<capSQLiteValues>;

/**
* Add SQLIte Suffix to existing databases
Expand Down Expand Up @@ -1734,13 +1734,11 @@ export class SQLiteConnection implements ISQLiteConnection {
return Promise.reject(err);
}
}
async getMigratableDbList(folderPath: string): Promise<capSQLiteValues> {
if (!folderPath || folderPath.length === 0) {
return Promise.reject('You must provide a folder path');
}
async getMigratableDbList(folderPath?: string): Promise<capSQLiteValues> {
const path: string = folderPath ? folderPath : 'default';
try {
const res = await this.sqlite.getMigratableDbList({
folderPath: folderPath,
folderPath: path,
});
return Promise.resolve(res);
} catch (err) {
Expand Down

0 comments on commit 548cd9a

Please sign in to comment.