TeamSpeak-3-Java-API
TeamSpeak-3-Java-API copied to clipboard
uploadIcon() should delete the icon when the upload fails (or override it)
Problem Description
If you upload an icon but the upload fails, the icon is somehow create on the teamspeak side but actually not uploaded. So if you try to upload the icon the second time, the upload fails, because the file already exists. Tho this error is not reported back. The exception is only thrown on the first attempt. For all later attempts there is internally a "file already exists" exception but it is not thrown back.
What can cause the problem?
- File transfer port not open on remote machine
Possible solutions
Delete the icon after failure
Once the upload failed, delete the icon via the ID. This will prevent the CRC created id being "blocked" for further uploads.
Set the override property to "true"
Since the uploader most likely wants to replace the icons anyways this would prevent the "file already exists" error and the upload can fail as often as wanted. You also can check if an icon is already present beforehand.
https://github.com/TheHolyWaffle/TeamSpeak-3-Java-API/blob/master/src/main/java/com/github/theholywaffle/teamspeak3/TS3ApiAsync.java#L5234
uploadFileDirect(data, path, false, 0) // < Change this to true
.onSuccess(__ -> future.set(iconId))
.onFailure(transformError(future, 2050, iconId));