Skip to content

Commit

Permalink
[expo-file-system] The background session doesn't fail if connection …
Browse files Browse the repository at this point in the history
…is down (#8593)

* [expo-file-system] Fix test-suite & update docs

* Update filesystem.md

Co-authored-by: Tomasz Sapeta <1714764+tsapeta@users.noreply.github.com>

Co-authored-by: Tomasz Sapeta <1714764+tsapeta@users.noreply.github.com>
  • Loading branch information
lukmccall and tsapeta committed Jun 1, 2020
1 parent 82c5cb0 commit bd1e8f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/test-suite/tests/FileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,10 @@ export async function test({ describe, expect, it, ...t }) {

let error;
try {
await FS.downloadAsync('https://nonexistent-subdomain.expo.io', localUri, { md5: true });
await FS.downloadAsync('https://nonexistent-subdomain.expo.io', localUri, {
md5: true,
sessionType: FS.FileSystemSessionType.FOREGROUND,
});
} catch (e) {
error = e;
}
Expand Down
3 changes: 3 additions & 0 deletions docs/pages/versions/unversioned/sdk/filesystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ These values can be used to define how data is read / written.
These values can be used to define how sessions work on iOS.

- **FileSystem.FileSystemSessionType.BACKGROUND** -- Using this mode means that the downloading/uploading session on the native side will work even if the application is moved to background. If the task completes while the application is in background, the Promise will be either resolved immediately or (if the application execution has already been stopped) once the app is moved to foreground again.

> **Note**: The background session doesn't fail if the server or your connection is down. Rather, it continues retrying until the task succeeds or is canceled manually.
- **FileSystem.FileSystemSessionType.FOREGROUND** -- Using this mode means that downloading/uploading session on the native side will be terminated once the application becomes inactive (e.g. when it goes to background). Bringing the application to foreground again would trigger Promise rejection.

### `FileSystem.FileSystemUploadOptions`
Expand Down

0 comments on commit bd1e8f0

Please sign in to comment.