Skip to content

Commit

Permalink
fix: apply PR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
OS-martacarlos committed Feb 13, 2025
1 parent 42442f1 commit ebb05b6
Show file tree
Hide file tree
Showing 15 changed files with 253 additions and 211 deletions.
39 changes: 19 additions & 20 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,56 @@
---
name: 🚨 Bug Report
about: Report something not working
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

## Bug Report

### Capacitor Version

### Plugin Version
<!--
In what version of the plugin was this bug found?
Paste the output from the `npx cap doctor` command into the code block below. This will provide the versions of Capacitor packages and related dependencies.
-->

## Platforms affected
- [ ] Android
- [ ] iOS
- [ ] JavaScript
```
PASTE OUTPUT HERE
```

### Platform(s)

### Current Behavior
<!--
Describe how the bug manifests. Be specific.
List the platforms that this bug affects.
-->

### Current Behavior

<!--
Describe how the bug manifests. Be specific.
-->

### Expected Behavior

<!--
Describe what the behavior should be.
-->



### Code Reproduction

<!--
To isolate the cause of the problem, we ask you to provide a minimal sample application that demonstrates the issue.
For full instructions, see: https://github.com/ionic-team/capacitor/blob/master/CONTRIBUTING.md#creating-a-code-reproduction
-->



### Other Technical Details

<!--
Please provide the following information with your request and any other relevant technical details (versions of IDEs, local environment info, plugin information or links, etc).
-->



### Additional Context

<!--
List any other information that is relevant to your issue. Stack traces, related issues, suggestions on how to fix, Stack Overflow links, forum links, etc.
-->


28 changes: 13 additions & 15 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
---
name: ⚡️ Feature Request
about: Request a feature or change
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

## Feature Request

### Plugin

### Description
<!--
Describe the feature request. If your feature request is related to a problem, be sure to describe that as well.
List which plugin this feature is for.
-->

### Description

<!--
Describe the feature request. If your feature request is related to a problem, be sure to describe that as well.
-->

### Platform(s)

<!--
List the platforms for which this feature should be added.
-->
- [ ] Android
- [ ] iOS
- [ ] JavaScript


### Preferred Solution
<!-- Describe the solution you would prefer. -->


<!-- Describe the solution you would prefer. -->

### Alternatives
<!-- Describe alternative solutions or features you've considered, if any. -->


<!-- Describe alternative solutions or features you've considered, if any. -->

### Additional Context

<!--
List any other information that is relevant to your issue. Stack traces, related issues, suggestions on how to fix, Stack Overflow links, forum links, etc.
-->

14 changes: 6 additions & 8 deletions .github/ISSUE_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
## Description

<!--- Describe your changes in detail -->

## Context

<!--- Why is this change required? What problem does it solve? -->
<!--- Place the link to the issue here -->

## Type of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply -->

- [ ] Fix (non-breaking change which fixes an issue)
- [ ] Feature (non-breaking change which adds functionality)
- [ ] Refactor (cosmetic changes)
- [ ] Breaking change (change that would cause existing functionality to not work as expected)

## Platforms affected

- [ ] Android
- [ ] iOS
- [ ] JavaScript

## Tests

<!--- Describe how you tested your changes in detail -->
<!--- Include details of your test environment if relevant -->

## Screenshots (if appropriate)

## Checklist
<!--- Go over all the following items and put an `x` in all the boxes that apply -->
- [ ] Pull request title follows the format `RNMT-XXXX <title>`
- [ ] Code follows code style of this project
- [ ] CHANGELOG.md file is correctly updated
- [ ] Changes require an update to the documentation
- [ ] Documentation has been updated accordingly
17 changes: 9 additions & 8 deletions .github/workflows/reusable_build.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
name: "Build Plugin"

on:
on:
workflow_call:
secrets:
THE_GH_RELEASE_TOKEN:
required: false

jobs:
build:
runs-on: 'ubuntu-24.04'
runs-on: "ubuntu-24.04"
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.THE_GH_RELEASE_TOKEN || github.token }}

- name: 'Setup Tools'
- name: "Setup Tools"
uses: ./.github/actions/setup-tools

- name: 'Copy README.md in root'
- name: "Copy README.md in root"
working-directory: ./packages/capacitor-plugin
run: cp README.md README.md.original

- name: 'Build Packages'
- name: "Build Packages"
working-directory: ./packages/capacitor-plugin
run: npm run build

- name: 'Check README.md changes'
- name: "Check README.md changes"
working-directory: ./packages/capacitor-plugin
run: |
if ! cmp --silent README.md ../../README.md.original; then
if ! cmp --silent README.md README.md.original; then
echo "Detected README.md changes; Do 'npm run build' to update the docs."
exit 1
fi
fi
2 changes: 1 addition & 1 deletion packages/capacitor-plugin/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PackageDescription

let package = Package(
name: "FilesystemCapacitor",
platforms: [.iOS(.v13)],
platforms: [.iOS(.v14)],
products: [
.library(
name: "FilesystemCapacitor",
Expand Down
74 changes: 61 additions & 13 deletions packages/capacitor-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ const readFilePath = async () => {

<docgen-index>

* [`checkPermissions()`](#checkpermissions)
* [`requestPermissions()`](#requestpermissions)
* [`readFile(...)`](#readfile)
* [`readFileInChunks(...)`](#readfileinchunks)
* [`writeFile(...)`](#writefile)
Expand All @@ -140,6 +142,40 @@ const readFilePath = async () => {
<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

### checkPermissions()

```typescript
checkPermissions() => Promise<PermissionStatus>
```

Check read/write permissions.
Required on Android, only when using <a href="#directory">`Directory.Documents`</a> or
`Directory.ExternalStorage`.

**Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>

**Since:** 1.0.0

--------------------


### requestPermissions()

```typescript
requestPermissions() => Promise<PermissionStatus>
```

Request read/write permissions.
Required on Android, only when using <a href="#directory">`Directory.Documents`</a> or
`Directory.ExternalStorage`.

**Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>

**Since:** 1.0.0

--------------------


### readFile(...)

```typescript
Expand Down Expand Up @@ -174,7 +210,7 @@ Native only (not available in web)

**Returns:** <code>Promise&lt;<a href="#readfileresult">ReadFileResult</a>&gt;</code>

**Since:** 1.0.0
**Since:** 7.1.0

--------------------

Expand Down Expand Up @@ -362,6 +398,13 @@ Copy a file or directory
### Interfaces


#### PermissionStatus

| Prop | Type |
| ------------------- | ----------------------------------------------------------- |
| **`publicStorage`** | <code><a href="#permissionstate">PermissionState</a></code> |


#### ReadFileResult

| Prop | Type | Description | Since |
Expand All @@ -382,7 +425,7 @@ Copy a file or directory

| Prop | Type | Description | Since |
| --------------- | ------------------- | ---------------------------- | ----- |
| **`chunkSize`** | <code>number</code> | Size of the chunks in bytes. | 1.0.0 |
| **`chunkSize`** | <code>number</code> | Size of the chunks in bytes. | 7.1.0 |


#### WriteFileResult
Expand Down Expand Up @@ -450,12 +493,12 @@ Copy a file or directory

| Prop | Type | Description | Since |
| ---------------------- | ---------------------------------- | ------------------------------------------------------------------------------------ | ----- |
| **`name`** | <code>string</code> | Name of the file or directory. | |
| **`type`** | <code>'file' \| 'directory'</code> | Type of the file. | 1.0.0 |
| **`size`** | <code>number</code> | Size of the file in bytes. | 1.0.0 |
| **`creationTime`** | <code>number</code> | Time of creation in milliseconds. It's not available on Android 7 and older devices. | 1.0.0 |
| **`modificationTime`** | <code>number</code> | Time of last modification in milliseconds. | 1.0.0 |
| **`uri`** | <code>string</code> | The uri of the file. | 1.0.0 |
| **`name`** | <code>string</code> | Name of the file or directory. | 7.1.0 |
| **`type`** | <code>'file' \| 'directory'</code> | Type of the file. | 4.0.0 |
| **`size`** | <code>number</code> | Size of the file in bytes. | 4.0.0 |
| **`creationTime`** | <code>number</code> | Time of creation in milliseconds. It's not available on Android 7 and older devices. | 7.1.0 |
| **`modificationTime`** | <code>number</code> | Time of last modification in milliseconds. | 7.1.0 |
| **`uri`** | <code>string</code> | The uri of the file. | 4.0.0 |


#### ReaddirOptions
Expand Down Expand Up @@ -503,12 +546,17 @@ Copy a file or directory

| Prop | Type | Description | Since |
| --------- | ------------------- | -------------------------------------- | ----- |
| **`uri`** | <code>string</code> | The uri where the file was copied into | 1.0.0 |
| **`uri`** | <code>string</code> | The uri where the file was copied into | 4.0.0 |


### Type Aliases


#### PermissionState

<code>'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'</code>


#### StatResult

<code><a href="#fileinfo">FileInfo</a></code>
Expand All @@ -528,13 +576,13 @@ Copy a file or directory
| --------------------- | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **`Documents`** | <code>'DOCUMENTS'</code> | The Documents directory. On iOS it's the app's documents directory. Use this directory to store user-generated content. On Android it's the Public Documents folder, so it's accessible from other apps. It's not accesible on Android 10 unless the app enables legacy External Storage by adding `android:requestLegacyExternalStorage="true"` in the `application` tag in the `AndroidManifest.xml`. On Android 11 or newer the app can only access the files/folders the app created. | 1.0.0 |
| **`Data`** | <code>'DATA'</code> | The Data directory. On iOS it will use the Documents directory. On Android it's the directory holding application files. Files will be deleted when the application is uninstalled. | 1.0.0 |
| **`Library`** | <code>'LIBRARY'</code> | The Library directory. On iOS it will use the Library directory. On Android it's the directory holding application files. Files will be deleted when the application is uninstalled. | 1.0.0 |
| **`Library`** | <code>'LIBRARY'</code> | The Library directory. On iOS it will use the Library directory. On Android it's the directory holding application files. Files will be deleted when the application is uninstalled. | 1.1.0 |
| **`Cache`** | <code>'CACHE'</code> | The Cache directory. Can be deleted in cases of low memory, so use this directory to write app-specific files. that your app can re-create easily. | 1.0.0 |
| **`External`** | <code>'EXTERNAL'</code> | The external directory. On iOS it will use the Documents directory. On Android it's the directory on the primary shared/external storage device where the application can place persistent files it owns. These files are internal to the applications, and not typically visible to the user as media. Files will be deleted when the application is uninstalled. | 1.0.0 |
| **`ExternalStorage`** | <code>'EXTERNAL_STORAGE'</code> | The external storage directory. On iOS it will use the Documents directory. On Android it's the primary shared/external storage directory. It's not accesible on Android 10 unless the app enables legacy External Storage by adding `android:requestLegacyExternalStorage="true"` in the `application` tag in the `AndroidManifest.xml`. It's not accesible on Android 11 or newer. | 1.0.0 |
| **`ExternalCache`** | <code>'EXTERNAL_CACHE'</code> | The external cache directory. Android ONly On Android it's the primary shared/external cache. It's not accesible on Android 10 unless the app enables legacy External Storage by adding `android:requestLegacyExternalStorage="true"` in the `application` tag in the `AndroidManifest.xml`. It's not accesible on Android 11 or newer. | 1.0.0 |
| **`LibraryNoCloud`** | <code>'LIBRARY_NO_CLOUD'</code> | iOS only | 1.0.0 |
| **`Temporary`** | <code>'TEMPORARY'</code> | iOS only | 1.0.0 |
| **`ExternalCache`** | <code>'EXTERNAL_CACHE'</code> | The external cache directory. Android ONly On Android it's the primary shared/external cache. It's not accesible on Android 10 unless the app enables legacy External Storage by adding `android:requestLegacyExternalStorage="true"` in the `application` tag in the `AndroidManifest.xml`. It's not accesible on Android 11 or newer. | 7.1.0 |
| **`LibraryNoCloud`** | <code>'LIBRARY_NO_CLOUD'</code> | iOS only It maps to Library/NoCloud directory Files will be deleted when the application is uninstalled. | 7.1.0 |
| **`Temporary`** | <code>'TEMPORARY'</code> | iOS only The tmp/ directory. Files will be deleted when the application is uninstalled. | 7.1.0 |


#### Encoding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,18 +317,16 @@ public void downloadFile(
ExecutorService executor = Executors.newSingleThreadExecutor();
Handler handler = new Handler(Looper.getMainLooper());

executor.execute(
() -> {
try {
JSObject result = doDownloadInBackground(urlString, call, bridge, emitter);
handler.post(() -> callback.onSuccess(result));
} catch (Exception error) {
handler.post(() -> callback.onError(error));
} finally {
executor.shutdown();
}
executor.execute(() -> {
try {
JSObject result = doDownloadInBackground(urlString, call, bridge, emitter);
handler.post(() -> callback.onSuccess(result));
} catch (Exception error) {
handler.post(() -> callback.onError(error));
} finally {
executor.shutdown();
}
);
});
}

private JSObject doDownloadInBackground(String urlString, PluginCall call, Bridge bridge, HttpRequestHandler.ProgressEmitter emitter)
Expand Down
Loading

0 comments on commit ebb05b6

Please sign in to comment.