smartdevicelink/sdl_javascript_suite

File Manager will upload the same file multiple times

renonick87 opened this issue · 0 comments

Bug Report

When trying to load multiple of the same artwork and the file is not uploaded yet, the file will be uploaded multiple times. This is because we create multiple of the same upload operation and they all execute.

We should probably implement the upload / delete operation to check if the file needs to be uploaded at the time it would run instead of the manager figuring out if the operation should be created at all.

Reproduction Steps
  1. Create 99 SDLArtworks that are exactly the same
  2. Attempt to upload all 99 with the uploadFiles method.
Expected Behavior

The one artwork should only be uploaded 1 time.

Observed Behavior

The one artwork will be uploaded 99 times, slowing down the head unit like crazy.

Test Case, Sample Code, and / or Example App
const newFile = new SDL.manager.file.filetypes.SdlArtwork('sdl-logo-new', SDL.rpc.enums.FileType.GRAPHIC_PNG)
    .setFilePath(this._filePath);
const dupeFiles = [newFile, newFile, newFile, newFile, newFile, newFile, newFile, newFile, newFile];
await this._sdlManager.getFileManager().uploadFiles(dupeFiles);

The above file will be uploaded 9 separate times.