|
33 | 33 | import { ListFiles } from './../../rpc/messages/ListFiles.js'; |
34 | 34 | import { DeleteFile } from './../../rpc/messages/DeleteFile.js'; |
35 | 35 | import { _SubManagerBase } from '../_SubManagerBase.js'; |
| 36 | +import { Version } from './../../util/Version.js'; |
36 | 37 |
|
37 | 38 | class _FileManagerBase extends _SubManagerBase { |
38 | 39 | /** |
@@ -217,18 +218,33 @@ class _FileManagerBase extends _SubManagerBase { |
217 | 218 | * @returns {Boolean} - Whether file has been uploaded to core (true) or not (false) |
218 | 219 | */ |
219 | 220 | hasUploadedFile (sdlFile) { |
| 221 | + // this method's logic is more related to the iOS library than the Java library |
| 222 | + // https://github.com/smartdevicelink/sdl_ios/issues/827 - Older versions of Core had a bug where list files would cache incorrectly. |
| 223 | + const rpcMsgVersion = this._lifecycleManager.getSdlMsgVersion(); |
| 224 | + const rpcVersion = new Version() |
| 225 | + .setMajor(rpcMsgVersion.getMajorVersion()) |
| 226 | + .setMinor(rpcMsgVersion.getMinorVersion()) |
| 227 | + .setPatch(rpcMsgVersion.getPatchVersion()); |
| 228 | + |
220 | 229 | const filename = sdlFile.getName(); |
221 | 230 | const isPersistent = sdlFile.isPersistent(); |
222 | 231 | const remoteFiles = this._remoteFiles; |
223 | 232 | const ephemeralFiles = this._uploadedEphemeralFileNames; |
224 | 233 | const isInRemoteFiles = remoteFiles.indexOf(filename) !== -1; |
225 | 234 | const isInEphemeralFiles = ephemeralFiles.indexOf(filename) !== -1; |
226 | 235 |
|
227 | | - if (isPersistent) { |
228 | | - return isInRemoteFiles; |
229 | | - } else { // if it is not persistent it must be listed in both remote and ephemeral files. |
230 | | - return isInRemoteFiles && isInEphemeralFiles; |
| 236 | + if (new Version(4, 4, 0).isNewerThan(rpcVersion) === 1) { |
| 237 | + if (isPersistent) { |
| 238 | + return isInRemoteFiles; |
| 239 | + } else { // if it is not persistent it must be listed in both remote and ephemeral files. |
| 240 | + return isInRemoteFiles && isInEphemeralFiles; |
| 241 | + } |
| 242 | + } else if (isInRemoteFiles) { |
| 243 | + // If not connected to a system where the bug presents itself, we can trust the `remoteFileNames` |
| 244 | + return true; |
231 | 245 | } |
| 246 | + |
| 247 | + return false; |
232 | 248 | } |
233 | 249 |
|
234 | 250 |
|
|
0 commit comments