Skip to content

Commit d86194c

Browse files
OCFile: parse localId with "oc" split
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
1 parent 96f9c3b commit d86194c

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

app/src/main/java/com/owncloud/android/datamodel/OCFile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,8 @@ public boolean isHidden() {
629629
public long getLocalId() {
630630
if (localId > 0) {
631631
return localId;
632-
} else if (remoteId != null && remoteId.length() > 8) {
633-
return Long.parseLong(remoteId.substring(0, 8).replaceAll("^0*", ""));
632+
} else if (remoteId != null) {
633+
return Long.parseLong(remoteId.split("oc")[0]);
634634
} else {
635635
return -1;
636636
}

app/src/test/java/com/owncloud/android/datamodel/OCFileTest.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
package com.owncloud.android.datamodel
99

1010
import org.junit.Assert.assertEquals
11-
import org.junit.Assert.assertNotEquals
1211
import org.junit.Test
1312

1413
class OCFileTest {
@@ -22,9 +21,8 @@ class OCFileTest {
2221
sut.remoteId = "00000008ocjycgrudn78"
2322
assertEquals(8, sut.localId)
2423

25-
// this will fail as fileId is too large
2624
sut.remoteId = "1234567891011ocjycgrudn78"
27-
assertNotEquals(1234567891011L, sut.localId)
25+
assertEquals(1234567891011L, sut.localId)
2826

2927
sut.localId = 1234567891011L
3028
assertEquals(1234567891011L, sut.localId)

0 commit comments

Comments
 (0)