Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: MWTELE 266 upload directory creation #248

Merged
merged 4 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) Red Hat 2023 */
/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights.config;

import static com.redhat.insights.InsightsErrorCode.ERROR_IDENTIFICATION_NOT_DEFINED;
Expand Down Expand Up @@ -123,6 +123,10 @@ public Optional<ProxyConfiguration> getProxyConfiguration() {

@Override
public boolean isOptingOut() {
String osName = System.getProperty("os.name");
if (osName != null && osName.trim().toLowerCase().contains("windows")) {
return true;
}
String value = lookup(ENV_OPT_OUT);
if (value != null) {
return "true".equalsIgnoreCase(value.trim());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) Red Hat 2023 */
/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights.config;

import java.time.Duration;
Expand Down Expand Up @@ -69,6 +69,10 @@ default Optional<ProxyConfiguration> getProxyConfiguration() {
}

default boolean isOptingOut() {
String osName = System.getProperty("os.name");
if (osName != null) {
return osName.trim().toLowerCase().contains("windows");
}
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public InsightsFileWritingClient(InsightsLogger logger, InsightsConfiguration co

private void ensureArchiveUploadDirExists() {
Path dir = Paths.get(config.getArchiveUploadDir());
if (Files.notExists(dir)) {
if (Files.notExists(dir) && !config.isOptingOut()) {
try {
Files.createDirectories(dir);
} catch (IOException e) {
Expand All @@ -46,6 +46,9 @@ public void decorate(InsightsReport report) {

@Override
public void sendInsightsReport(String filename, InsightsReport report) {
if (config.isOptingOut()) {
return;
}
decorate(report);

// Can't reuse upload path - as this may be called as part of fallback
Expand Down