Skip to content

Commit d8e4b52

Browse files
author
Julian Kast
committed
Added overWrite property check in baseFileManager uploadFiles
1 parent 032c400 commit d8e4b52

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

base/src/main/java/com/smartdevicelink/managers/file/BaseFileManager.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,23 @@ public void uploadFiles(@NonNull List<? extends SdlFile> files, final MultipleFi
402402
}
403403
final List<PutFile> putFileRequests = new ArrayList<>();
404404
for (SdlFile file : files) {
405-
if (!file.isStaticIcon()) {
406-
putFileRequests.add(createPutFile(file));
405+
if (file.isStaticIcon()) {
406+
Log.w(TAG, "Static icons don't need to be uploaded");
407+
continue;
407408
}
409+
// In sdl_ios: HAX: [#827](https://github.com/smartdevicelink/sdl_ios/issues/827) Older versions of Core had a bug where list files would cache incorrectly.
410+
// This led to attempted uploads failing due to the system thinking they were already there when they were not.
411+
if (!file.isPersistent() && !hasUploadedFile(file)) {
412+
file.setOverwrite(true);
413+
}
414+
if (!file.isOverwrite() && hasUploadedFile(file)) {
415+
Log.w(TAG, "Files that have already uploaded and have an Overwrite property set to false will now upload re-Upload");
416+
continue;
417+
}
418+
putFileRequests.add(createPutFile(file));
408419
}
409420
// if all files are static icons we complete listener with no errors
410421
if (putFileRequests.isEmpty()) {
411-
Log.w(TAG, "Static icons don't need to be uploaded");
412422
listener.onComplete(null);
413423
} else {
414424
final Map<String, String> errors = new HashMap<>();

0 commit comments

Comments
 (0)