Skip to content

Commit

Permalink
fix: reset api token on error so we fetch token again (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigboxer23 authored Nov 11, 2024
1 parent 76bddf0 commit 8cef278
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ private MediaType getMediaType(File file) {

/** Cause a re-fetch of all meural device information on next request */
public void reset() {
logger.warn("resetting api");
token = null;
meuralDevice = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ private MeuralResponse doAction(Command<Optional<SourceItem>> command) throws IO
api.previewItem(url, false);
url.setCleanupTempFile(true);
return api.changePicture(url);
} catch (IOException theE) {
logger.warn("doAction", theE);
} catch (IOException e) {
logger.warn("doAction", e);
api.reset();
return new MeuralResponse();
}
})
Expand Down
14 changes: 0 additions & 14 deletions src/test/java/com/bigboxer23/MeuralControllerAppTest.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,11 @@

import static org.junit.jupiter.api.Assertions.*;

import com.bigboxer23.meural_control.data.OpenAIImageGenerationBody;
import com.bigboxer23.meural_control.data.OpenAIImageGenerationResponse;
import com.bigboxer23.meural_control.data.SourceItem;
import com.bigboxer23.utils.http.OkHttpUtil;
import com.squareup.moshi.Moshi;
import java.io.IOException;
import java.util.Optional;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

Expand Down

0 comments on commit 8cef278

Please sign in to comment.