Skip to content

Commit

Permalink
enqueue action option rename
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyofrancis committed Jun 26, 2018
1 parent 62ae5c5 commit 5e4fcb0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 2.1.0-RC9
- Renamed enqueue option EnqueueAction.THROW_ERROR_IF_EXISTING to EnqueueAction.DO_NOT_ENQUEUE_IF_EXISTING
to better reflect the action intention.

Version 2.1.0-RC8
- Added new Enqueue Action option: EnqueueAction.THROW_ERROR_IF_EXISTING. See java docs for details.
- Added Error option : Error.REQUEST_WITH_FILE_PATH_ALREADY_EXIST
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

[![Build Status](https://travis-ci.org/tonyofrancis/Fetch.svg?branch=v2)](https://travis-ci.org/tonyofrancis/Fetch)
[ ![Download](https://api.bintray.com/packages/tonyofrancis/maven/fetch2/images/download.svg?version=2.1.0-RC8) ](https://bintray.com/tonyofrancis/maven/fetch2/2.1.0-RC8/link)
[ ![Download](https://api.bintray.com/packages/tonyofrancis/maven/fetch2/images/download.svg?version=2.1.0-RC9) ](https://bintray.com/tonyofrancis/maven/fetch2/2.1.0-RC9/link)
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Android%20Networking-blue.svg?style=flat)](https://android-arsenal.com/details/1/5196)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/tonyofrancis/Fetch/blob/master/LICENSE)

Expand Down Expand Up @@ -48,7 +48,7 @@ How to use Fetch
Using Fetch is easy! Just add the Gradle dependency to your application's build.gradle file.

```java
implementation "com.tonyodev.fetch2:fetch2:2.1.0-RC8"
implementation "com.tonyodev.fetch2:fetch2:2.1.0-RC9"
```

Next, get an instance of Fetch and request a download.
Expand Down Expand Up @@ -214,7 +214,7 @@ to use the OkHttp Downloader instead. You can create your own custom downloaders
if necessary. See the Java docs for details.

```java
implementation "com.tonyodev.fetch2okhttp:fetch2okhttp:2.1.0-RC8"
implementation "com.tonyodev.fetch2okhttp:fetch2okhttp:2.1.0-RC9"
```
Set the OkHttp Downloader for Fetch to use.
```java
Expand All @@ -235,7 +235,7 @@ If you would like to take advantage of RxJava2 features when using Fetch,
add the following gradle dependency to your application's build.gradle file.

```java
implementation "com.tonyodev.fetch2rx:fetch2rx:2.1.0-RC8"
implementation "com.tonyodev.fetch2rx:fetch2rx:2.1.0-RC9"
```

RxFetch makes it super easy to enqueue download requests and query downloads using rxJava2 functional methods.
Expand Down Expand Up @@ -271,7 +271,7 @@ added in the coming days.

Start using FetchFileServer by adding the gradle dependency to your application's build.gradle file.
```java
implementation "com.tonyodev.fetch2fileserver:fetch2fileserver:2.1.0-RC8"
implementation "com.tonyodev.fetch2fileserver:fetch2fileserver:2.1.0-RC9"
```

Start a FetchFileServer instance and add resource files that it can server to connected clients.
Expand Down Expand Up @@ -309,7 +309,7 @@ public class TestActivity extends AppCompatActivity {
Download a file from a FetchFileServer using the Fetch. Add the FetchFileServerDownloader
dependency to you app's build.gradle file.
```java
implementation "com.tonyodev.fetch2downloaders:fetch2downloaders:2.1.0-RC8"
implementation "com.tonyodev.fetch2downloaders:fetch2downloaders:2.1.0-RC9"
```

Then create an instance of Fetch and enqueue the download.
Expand Down Expand Up @@ -463,7 +463,7 @@ Fetch1 Migration

Migrate downloads from Fetch1 to Fetch2 using the migration assistant. Add the following gradle dependency to your application's build.gradle file.
```java
implementation "com.tonyodev.fetchmigrator:fetchmigrator:2.1.0-RC8"
implementation "com.tonyodev.fetchmigrator:fetchmigrator:2.1.0-RC9"
```
Then run the Migrator.
Expand Down
6 changes: 3 additions & 3 deletions fetch2/src/main/java/com/tonyodev/fetch2/EnqueueAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ enum class EnqueueAction(val value: Int) {
* Example: text.txt, text(1).txt, text(2).txt.*/
INCREMENT_FILE_NAME(1),

/** An error is thrown if an existing request/download is found with the same filename.*/
THROW_ERROR_IF_EXISTING(2);
/** Fetch will not enqueue the new request if a request already managed by Fetch has the same file path. */
DO_NOT_ENQUEUE_IF_EXISTING(2);

companion object {

@JvmStatic
fun valueOf(value: Int): EnqueueAction {
return when (value) {
1 -> INCREMENT_FILE_NAME
2 -> THROW_ERROR_IF_EXISTING
2 -> DO_NOT_ENQUEUE_IF_EXISTING
else -> REPLACE_EXISTING
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FetchHandlerImpl(private val namespace: String,

private fun prepareDownloadInfoForEnqueue(downloadInfo: DownloadInfo) {
val existingDownload = databaseManager.getByFile(downloadInfo.file)
if (downloadInfo.enqueueAction == EnqueueAction.THROW_ERROR_IF_EXISTING && existingDownload != null) {
if (downloadInfo.enqueueAction == EnqueueAction.DO_NOT_ENQUEUE_IF_EXISTING && existingDownload != null) {
throw FetchException(REQUEST_WITH_FILE_PATH_ALREADY_EXIST, FetchException.Code.REQUEST_WITH_FILE_PATH_ALREADY_EXIST)
} else if (downloadInfo.enqueueAction == EnqueueAction.REPLACE_EXISTING && existingDownload != null) {
if (isDownloading(existingDownload.id)) {
Expand Down
4 changes: 2 additions & 2 deletions versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ ext {
rxAndroid2_version = "2.0.2"
timber_version = "4.7.0"
novoda_bintray_version = "0.8.0"
library_version = "2.1.0-RC8"
library_version_code = 31
library_version = "2.1.0-RC9"
library_version_code = 32
}

0 comments on commit 5e4fcb0

Please sign in to comment.