Skip to content

Commit faa58a1

Browse files
Fixed bug #5876 (#6086)
1 parent d275159 commit faa58a1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

app/src/main/java/fr/free/nrw/commons/upload/worker/UploadWorker.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,8 @@ class UploadWorker(
481481
)
482482
if (null != revisionID) {
483483
withContext(Dispatchers.IO) {
484-
val place = placesRepository.fetchPlace(wikiDataPlace.id);
485-
place.name = wikiDataPlace.name;
484+
val place = placesRepository.fetchPlace(wikiDataPlace.id)
485+
place.name = wikiDataPlace.name
486486
place.pic = HOME_URL + uploadResult.createCanonicalFileName()
487487
placesRepository
488488
.save(place)
@@ -568,12 +568,18 @@ class UploadWorker(
568568

569569
sequenceFileName =
570570
if (fileName.indexOf('.') == -1) {
571-
"$fileName #$randomHash"
571+
// Append the random hash in parentheses if no file extension is present
572+
"$fileName ($randomHash)"
572573
} else {
573574
val regex =
574575
Pattern.compile("^(.*)(\\..+?)$")
575576
val regexMatcher = regex.matcher(fileName)
576-
regexMatcher.replaceAll("$1 #$randomHash")
577+
// Append the random hash in parentheses before the file extension
578+
if (regexMatcher.find()) {
579+
"${regexMatcher.group(1)} ($randomHash)${regexMatcher.group(2)}"
580+
} else {
581+
"$fileName ($randomHash)"
582+
}
577583
}
578584
}
579585
return sequenceFileName!!

0 commit comments

Comments
 (0)