mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 09:00:26 +00:00
File mkdirs fixes
This commit is contained in:
parent
f5b238bd45
commit
ba5e056f82
8 changed files with 14 additions and 13 deletions
|
@ -50,7 +50,7 @@ public class BlobManager {
|
|||
|
||||
public Path newBlobFile() throws IOException {
|
||||
var file = TEMP.resolve(UUID.randomUUID().toString());
|
||||
Files.createDirectories(file.getParent());
|
||||
FileUtils.forceMkdir(file.getParent().toFile());
|
||||
return file;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import javafx.scene.web.WebEngine;
|
|||
import javafx.scene.web.WebView;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
@ -63,7 +64,7 @@ public class MarkdownComp extends Comp<CompStructure<StackPane>> {
|
|||
var html = MarkdownHelper.toHtml(markdown, s -> s, htmlTransformation, null);
|
||||
try {
|
||||
// Workaround for https://bugs.openjdk.org/browse/JDK-8199014
|
||||
Files.createDirectories(file.getParent());
|
||||
FileUtils.forceMkdir(file.getParent().toFile());
|
||||
Files.writeString(file, html);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.xpipe.app.core;
|
||||
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.channels.FileChannel;
|
||||
|
@ -21,7 +22,7 @@ public class AppDataLock {
|
|||
public static boolean lock() {
|
||||
try {
|
||||
var file = getLockFile().toFile();
|
||||
Files.createDirectories(file.toPath().getParent());
|
||||
FileUtils.forceMkdir(file.getParentFile());
|
||||
if (!Files.exists(file.toPath())) {
|
||||
try {
|
||||
// It is possible that another instance creates the lock at almost the same time
|
||||
|
|
|
@ -138,7 +138,7 @@ public class AppLogs {
|
|||
var shouldLogToFile = shouldWriteLogs();
|
||||
if (shouldLogToFile) {
|
||||
try {
|
||||
Files.createDirectories(usedLogsDir);
|
||||
FileUtils.forceMkdir(usedLogsDir.toFile());
|
||||
var file = usedLogsDir.resolve("xpipe.log");
|
||||
var fos = new FileOutputStream(file.toFile(), true);
|
||||
var buf = new BufferedOutputStream(fos);
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.xpipe.app.core.check;
|
|||
|
||||
import io.xpipe.app.core.AppProperties;
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
@ -12,9 +13,9 @@ public class AppUserDirectoryCheck {
|
|||
var dataDirectory = AppProperties.get().getDataDir();
|
||||
|
||||
try {
|
||||
Files.createDirectories(dataDirectory);
|
||||
FileUtils.forceMkdir(dataDirectory.toFile());
|
||||
var testDirectory = dataDirectory.resolve("permissions_check");
|
||||
Files.createDirectories(testDirectory);
|
||||
FileUtils.forceMkdir(testDirectory.toFile());
|
||||
Files.delete(testDirectory);
|
||||
// if (true) throw new IOException();
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -14,18 +14,16 @@ import io.xpipe.app.terminal.ExternalTerminalType;
|
|||
import io.xpipe.app.util.PasswordLockSecretValue;
|
||||
import io.xpipe.core.util.InPlaceSecretValue;
|
||||
import io.xpipe.core.util.ModuleHelper;
|
||||
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.*;
|
||||
import javafx.beans.value.ObservableBooleanValue;
|
||||
import javafx.beans.value.ObservableDoubleValue;
|
||||
import javafx.beans.value.ObservableStringValue;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Value;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
|
@ -490,7 +488,7 @@ public class AppPrefs {
|
|||
}
|
||||
|
||||
try {
|
||||
Files.createDirectories(storageDirectory.get());
|
||||
FileUtils.forceMkdir(storageDirectory.getValue().toFile());
|
||||
} catch (Exception e) {
|
||||
ErrorEvent.fromThrowable(e).expected().build().handle();
|
||||
storageDirectory.setValue(DEFAULT_STORAGE_DIR);
|
||||
|
|
|
@ -437,7 +437,7 @@ public class StandardStorage extends DataStorage {
|
|||
var s = Files.readString(file);
|
||||
vaultKey = new String(Base64.getDecoder().decode(s), StandardCharsets.UTF_8);
|
||||
} else {
|
||||
Files.createDirectories(dir);
|
||||
FileUtils.forceMkdir(dir.toFile());
|
||||
vaultKey = UUID.randomUUID().toString();
|
||||
Files.writeString(file, Base64.getEncoder().encodeToString(vaultKey.getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
@ -458,7 +458,7 @@ public class StandardStorage extends DataStorage {
|
|||
Files.writeString(file, s);
|
||||
}
|
||||
} else {
|
||||
Files.createDirectories(dir);
|
||||
FileUtils.forceMkdir(dir.toFile());
|
||||
var s = OsType.getLocal().getName();
|
||||
Files.writeString(file, s);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class ShellTemp {
|
|||
temp = temp.resolve(user != null ? user : "user");
|
||||
|
||||
try {
|
||||
Files.createDirectories(temp);
|
||||
FileUtils.forceMkdir(temp.toFile());
|
||||
// We did not set this in earlier versions. If we are running as a different user, it might fail
|
||||
Files.setPosixFilePermissions(temp, PosixFilePermissions.fromString("rwxrwxrwx"));
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in a new issue