+ switch to external logger

+ clean legacy code
pull/1/head
io42630 3 years ago
parent 9113eeebb9
commit b28155a752

@ -30,6 +30,16 @@ DataRoot a data root
<br>
### Flow
* `for` each `SyncBundle`
* `for` each `SyncDirectory`
* check what files were CRUD,
* propagate to other `SyncDirectory` of current `SyncBundle`.
<br>
### Demo<a name="demo"></a>
[![IMAGE ALT TEXT](http://img.youtube.com/vi/znR3jyM_4Ss/0.jpg)](https://youtu.be/znR3jyM_4Ss "ensync WIP Demo")

@ -1,26 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.olexyn.ensync</groupId>
<artifactId>ensync</artifactId>
<version>0.1</version>
<name>ensync</name>
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<vaadin.version>7.3.1</vaadin.version>
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
<failOnMissingWebXml>false</failOnMissingWebXml>
<maven.compiler.source>1.11</maven.compiler.source>
<maven.compiler.target>1.11</maven.compiler.target>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
<kotlin.version>1.6.20-RC2</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
@ -54,17 +47,20 @@
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>com.olexyn.min.log</groupId>
<artifactId>min-log</artifactId>
<version>0.1.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<pluginManagement>
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
@ -89,7 +85,6 @@
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
@ -122,7 +117,7 @@
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
<jvmTarget>18</jvmTarget>
</configuration>
</plugin>
<plugin>

@ -1,54 +0,0 @@
package com.olexyn.ensync;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
public class Execute {
/**
* @param cmd an array representing a shell command
* @return <i>TwoBr</i> class, containing two BufferedReaders,
* <i>output</i> and <i>error</i>
* @see <i>output</i> BufferedReader, corresponds to STDOUT
* <i>error</i> BufferedReader, corresponds to STDERR
*/
public TwoBr execute(String cmd[]) {
TwoBr twobr = new TwoBr();
try {
Process process = Runtime.getRuntime().exec(cmd);
process.waitFor();
twobr.output = new BufferedReader(new InputStreamReader(process.getInputStream()));
twobr.error = new BufferedReader(new InputStreamReader(process.getErrorStream()));
} catch (Exception e) {
e.printStackTrace();
}
return twobr;
}
public TwoBr execute(List<String> cmd) {
String[] cmdArr = new String[cmd.size()];
for (int i = 0; i < cmd.size(); i++) {
cmdArr[i] = cmd.get(i);
}
return execute(cmdArr);
}
public void executeBatch(List<String[]> batch) {
for (String[] strings : batch) {
execute(strings);
}
}
public class TwoBr {
public BufferedReader output;
public BufferedReader error;
}
}

@ -4,21 +4,19 @@ import com.olexyn.ensync.artifacts.DataRoot;
import com.olexyn.ensync.artifacts.Record;
import com.olexyn.ensync.artifacts.SyncDirectory;
import com.olexyn.ensync.lock.LockKeeper;
import com.olexyn.min.log.LogU;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Logger;
import java.util.stream.Collectors;
public class Flow implements Runnable {
private static final Logger LOGGER = LogUtil.get(Flow.class);
public static final long POLLING_PAUSE = 100;
private final AtomicBoolean running = new AtomicBoolean(false);
public void start() {
LOGGER.info("START Flow.");
LogU.infoStart("Flow");
Thread worker = new Thread(this, "FLOW_WORKER");
worker.start();
}
@ -48,10 +46,10 @@ public class Flow implements Runnable {
);
}
try {
LOGGER.info("Sleeping... for " + POLLING_PAUSE + "ms.");
LogU.infoPlain("Sleeping... for %sms", POLLING_PAUSE);
Thread.sleep(POLLING_PAUSE);
} catch (InterruptedException ignored) {
LOGGER.info("Thread interrupted.");
LogU.warnPlain("Thread interrupted.");
}
}
}
@ -60,19 +58,21 @@ public class Flow implements Runnable {
*
*/
private void sync(SyncDirectory sDir) {
LOGGER.info("DO SYNC " + sDir.directoryPath);
LogU.infoPlain("DO SYNC %s", sDir.directoryPath);
var listFileSystem = sDir.readFileSystem();
LOGGER.info("# FS: " + listFileSystem.size());
LogU.infoPlain("# FS: %s", listFileSystem.size());
var record = new Record(sDir.directoryPath);
record.getFiles().putAll(sDir.readRecord());
LOGGER.info("# Record: " + record.getFiles().size());
LogU.infoPlain("# Record: %s", record.getFiles().size());
var listCreated = sDir.fillListOfLocallyCreatedFiles(listFileSystem, record);
LOGGER.info("# Created: " + listCreated.size());
var listDeleted = sDir.makeListOfLocallyDeletedFiles(listFileSystem, record);
LOGGER.info("# Deleted: " + listDeleted.size());
var listModified = sDir.makeListOfLocallyModifiedFiles(listFileSystem, record);
LOGGER.info("# Modified: " + listModified.size());
Tools tools = new Tools();
int newly = tools.setMinus(listCreated.keySet(), listDeleted.keySet()).size();
LogU.infoPlain("# Created: %s\n thereof newly created (not mv) %s", listCreated.size(), newly);
LogU.infoPlain("# Deleted: %s", listDeleted.size());
LogU.infoPlain("# Modified: %s", listModified.size());
sDir.doCreateOpsOnOtherSDs(listCreated);
sDir.doDeleteOpsOnOtherSDs(listDeleted);

@ -1,50 +0,0 @@
package com.olexyn.ensync;
import java.io.IOException;
import java.util.Date;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
public class LogUtil {
private static final String format = "[%1$tF %1$tT] [%4$-7s] %5$-100s [%2$s]\n";
public static Logger get(Class<?> c) {
return get(c, Level.INFO);
}
public static Logger get(Class<?> c, Level level) {
System.setProperty("java.util.logging.SimpleFormatter.format", format);
Logger logger = Logger.getLogger(c.getName());
try {
String dir = System.getProperty("user.dir") + "/logs/main.log";
FileHandler fh = new FileHandler(dir, true);
fh.setFormatter(new SimpleFormatter() {
@Override
public synchronized String format(LogRecord logRecord) {
String msg = logRecord.getMessage();
return String.format(format,
new Date(logRecord.getMillis()),
logRecord.getSourceClassName() + " " + logRecord.getSourceMethodName(),
"",
logRecord.getLevel().getLocalizedName(),
msg
);
}
});
logger.addHandler(fh);
logger.setLevel(level);
} catch (NullPointerException | IOException e) {
e.printStackTrace();
}
return logger;
}
}

@ -4,6 +4,7 @@ import com.olexyn.ensync.artifacts.DataRoot;
import com.olexyn.ensync.artifacts.SyncBundle;
import com.olexyn.ensync.lock.LockUtil;
import com.olexyn.ensync.util.IgnoreUtil;
import com.olexyn.min.log.LogU;
import org.json.JSONException;
import org.json.JSONObject;
@ -17,6 +18,7 @@ public class MainApp {
final private static Tools TOOLS = new Tools();
public static void main(String[] args) throws JSONException {
LogU.remake(null, "com.olexyn.ensync.", "[%1$tF %1$tT] [%2$-7s] [%3$-10s] %4$-180s [%5$s]\n");
var configPath = Path.of(System.getProperty("user.dir") + "/src/main/resources/config.json");
String configString = Tools.fileToString(LockUtil.lockFile(configPath).getFc());

@ -1,6 +0,0 @@
package com.olexyn.ensync;
public enum OperationMode {
JAVA_FX,
JSON
}

@ -1,9 +1,9 @@
package com.olexyn.ensync.artifacts;
import com.olexyn.ensync.LogUtil;
import com.olexyn.ensync.Tools;
import com.olexyn.ensync.lock.LockKeeper;
import com.olexyn.ensync.util.IgnoreUtil;
import com.olexyn.min.log.LogU;
import org.apache.commons.io.FileUtils;
import java.io.File;
@ -21,8 +21,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -34,7 +32,6 @@ import static com.olexyn.ensync.artifacts.Constants.RECORD_SEPARATOR;
*/
public class SyncDirectory {
private static final Logger LOGGER = LogUtil.get(SyncDirectory.class);
private final SyncBundle syncMap;
public Path directoryPath;
Tools tools = new Tools();
@ -136,7 +133,7 @@ public class SyncDirectory {
var i = new BigInteger(1, m.digest());
return String.format("%1$032X", i);
} catch (Exception e) {
LOGGER.log(Level.INFO, "Failed to create Hash.", e);
LogU.warnPlain("Failed to create Hash.\n%s", e.getMessage());
return null;
}
}
@ -159,7 +156,7 @@ public class SyncDirectory {
outputList.add(line);
});
LOGGER.info("Writing " + outputList.size() + " files to Record: " + record.getPath());
LogU.infoPlain("Writing " + outputList.size() + " files to Record: " + record.getPath());
tools.writeStringListToFile(record.getPath().toString(), outputList);
}
@ -173,7 +170,7 @@ public class SyncDirectory {
.filter(file -> IgnoreUtil.noIgnore(file.toPath()))
.filter(file -> !file.getName().equals(Constants.STATE_FILE_NAME));
} catch (IOException e) {
LOGGER.severe("Could walk the file tree : Record will be empty.");
LogU.warnPlain("Could walk the file tree : Record will be empty.");
return Stream.empty();
}
}
@ -187,11 +184,14 @@ public class SyncDirectory {
}
public void doDeleteOpsOnOtherSDs(Map<String, RecordFile> listDeleted) {
int deleteCount = 0;
for (var deletedFile : listDeleted.values()) {
for (var otherFile : otherFiles(deletedFile)) {
deleteFileIfNewer(deletedFile, otherFile);
var ok = deleteFileIfNewer(deletedFile, otherFile);
if (ok) { deleteCount++; }
}
}
LogU.infoPlain("DELETED " + deleteCount + "/" + listDeleted.size() + " Files.");
}
public void doModifyOpsOnOtherSDs(Map<String, SyncFile> listModified) {
@ -214,26 +214,31 @@ public class SyncDirectory {
* Here the >= is crucial, since otherFile might have == modified,
* but in that case we still want to delete both files.
*/
private void deleteFileIfNewer(RecordFile thisFile, SyncFile otherFile) {
private boolean deleteFileIfNewer(RecordFile thisFile, SyncFile otherFile) {
if (!otherFile.exists()) {
LOGGER.info("Could not delete: " + otherFile.toPath() + " not found.");
return; }
LogU.infoPlain("Not deleted (not found) " + otherFile.toPath() + " not found.");
return false;
}
if (thisFile.lastModified() >= otherFile.lastModified()) {
try {
Files.delete(otherFile.toPath());
LOGGER.info("Deleted: " + otherFile.toPath());
LogU.infoPlain("Deleted " + otherFile.toPath());
return true;
} catch (IOException e) {
LOGGER.info("Could not delete: " + otherFile.toPath());
LogU.infoPlain("Not deleted (IOE) " + otherFile.toPath());
return false;
}
}
LogU.infoPlain("Not deleted (other file modified recently)");
return false;
}
/**
* Overwrite other file if this file is newer.
*/
private void writeFileIfNewer(SyncFile thisFile, SyncFile otherFile) {
LOGGER.info("Try write from: " + thisFile.toPath());
LOGGER.info(" to: " + otherFile.toPath());
LogU.infoPlain("Try write from: " + thisFile.toPath());
LogU.infoPlain(" to: " + otherFile.toPath());
if (!thisFile.isFile()) { return; }
if (otherFile.exists()) {
var thisHash = getHash(thisFile.toPath());
@ -243,7 +248,7 @@ public class SyncDirectory {
dropAge(thisFile, otherFile);
return;
} else if (thisFile.lastModified() <= otherFile.lastModified()) {
LOGGER.info("Did not override due to target being newer.");
LogU.infoPlain("Did not override due to target being newer.");
return;
}
}
@ -252,15 +257,15 @@ public class SyncDirectory {
private void dropAge(SyncFile thisFile, SyncFile otherFile) {
if (thisFile.lastModified() == otherFile.lastModified()) {
LOGGER.info("Same age, ignore");
LogU.infoPlain("Same age, ignore");
return;
}
if (thisFile.lastModified() < otherFile.lastModified()) {
otherFile.setLastModified(thisFile.lastModified());
LOGGER.info("Dropped age of: " + otherFile.toPath() + " -> " + otherFile.lastModified());
LogU.infoPlain("Dropped age of: %s -> %s",otherFile.toPath(), otherFile.lastModified());
} else {
thisFile.setLastModified(otherFile.lastModified());
LOGGER.info("Dropped age of: " + thisFile.toPath() + " -> " + thisFile.lastModified());
LogU.infoPlain("Dropped age of: %s -> %s",thisFile.toPath(), thisFile.lastModified());
}
}
@ -269,7 +274,7 @@ public class SyncDirectory {
try {
FileUtils.createParentDirectories(otherFile);
} catch (IOException e) {
LOGGER.info("Could not create Parent");
LogU.warnPlain("Could not create Parent");
}
}
var thisFc = LockKeeper.getFc(thisFile.toPath());
@ -280,14 +285,15 @@ public class SyncDirectory {
) {
copyStream(is, os);
} catch (Exception e) {
LOGGER.severe("Could not copy file from: " + thisFile.toPath());
LOGGER.severe(" to: " + otherFile.toPath());
LogU.warnPlain("Could not copy file from: %s", thisFile.toPath());
LogU.warnPlain(" to: %s", otherFile.toPath());
e.printStackTrace();
}
LOGGER.info(thisFile.toPath() + " "+ thisFile.lastModified());
LOGGER.info(otherFile.toPath() + " " + otherFile.lastModified());
LogU.infoPlain(thisFile.toPath() + " "+ thisFile.lastModified());
LogU.infoPlain(otherFile.toPath() + " " + otherFile.lastModified());
otherFile.setLastModified(thisFile.lastModified());
LOGGER.info(otherFile.toPath() + " " + otherFile.lastModified());
LogU.infoPlain(otherFile.toPath() + " " + otherFile.lastModified());
}
public static void copyStream(InputStream input, OutputStream output)

@ -1,15 +1,13 @@
package com.olexyn.ensync.artifacts;
import com.olexyn.ensync.LogUtil;
import com.olexyn.min.log.LogU;
import java.io.File;
import java.util.logging.Logger;
import static com.olexyn.ensync.artifacts.Constants.EMPTY;
public class SyncFile extends File {
private static final Logger LOGGER = LogUtil.get(SyncFile.class);
private final String relativePath;
private final SyncDirectory sDir;
@ -36,8 +34,8 @@ public class SyncFile extends File {
@Override
public long lastModified(){
if (exists()) { return super.lastModified(); }
LOGGER.info("Did not find File for " + this);
LOGGER.info("Returning -1 (never existed).");
LogU.infoPlain("Did not find File for " + this);
LogU.infoPlain("Returning -1 (never existed).");
return -1;
}

@ -1,7 +1,7 @@
package com.olexyn.ensync.lock;
import com.olexyn.ensync.LogUtil;
import com.olexyn.ensync.util.IgnoreUtil;
import com.olexyn.min.log.LogU;
import java.io.IOException;
import java.nio.channels.FileChannel;
@ -10,15 +10,12 @@ import java.nio.file.Path;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import java.util.stream.Collectors;
public class LockKeeper {
private static final int TRY_COUNT = 4;
private static final Logger LOGGER = LogUtil.get(LockKeeper.class);
private final static Map<Path, FcState> LOCKS = new HashMap<>();
public static boolean lockDir(Path dirPath) {
@ -32,7 +29,7 @@ public class LockKeeper {
} catch (IOException e) {
return false;
}
LOGGER.info("LOCKED " + fcStates.size() + " files in " + dirPath);
LogU.infoPlain("LOCKED " + fcStates.size() + " files in " + dirPath);
fcStates.forEach(fcState -> LOCKS.put(fcState.getPath(), fcState));
return fcStates.stream().noneMatch(FcState::isUnlocked);
}
@ -40,7 +37,7 @@ public class LockKeeper {
public static void unlockAll() {
LOGGER.info("UNLOCKING ALL.");
LogU.infoPlain("UNLOCKING ALL.");
LOCKS.values().forEach(
fcState -> LockUtil.unlockFile(fcState.getPath(), fcState.getFc(), 4)
);

@ -1,34 +1,28 @@
package com.olexyn.ensync.lock;
import com.olexyn.ensync.LogUtil;
import com.olexyn.min.log.LogU;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.channels.OverlappingFileLockException;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.logging.Level;
import java.util.logging.Logger;
import static java.nio.file.StandardOpenOption.APPEND;
import static java.nio.file.StandardOpenOption.CREATE_NEW;
import static java.nio.file.StandardOpenOption.READ;
import static java.nio.file.StandardOpenOption.WRITE;
import static java.util.logging.Level.INFO;
public class LockUtil {
private static final int DEFAULT_LOCK_TRIES = 4;
private static final long SLEEP_DURATION = 1000;
private static final Logger LOGGER = LogUtil.get(LockUtil.class);
public static FcState newFile(Path filePath) {
try {
var fc = FileChannel.open(filePath, CREATE_NEW, WRITE);
return new FcState(filePath, fc, false);
} catch (IOException | OverlappingFileLockException e) {
LOGGER.log(INFO, "Could not NEW " + filePath, e);
LogU.warnPlain("Could not NEW %s\n%s", filePath, e.getMessage());
return new FcState(filePath, null, false);
}
}
@ -47,13 +41,13 @@ public class LockUtil {
} catch (IOException | OverlappingFileLockException e) {
if (tryCount > 0) {
tryCount--;
LOGGER.info("Could not lock " + filePath + " Will try " + tryCount + " times.");
LogU.warnPlain("Could not lock %s. Will try %s times.", filePath, tryCount);
try {
Thread.sleep(SLEEP_DURATION);
} catch (InterruptedException ignored) { }
return lockFile(filePath, tryCount);
}
LOGGER.log(INFO, "Could not lock " + filePath, e);
LogU.warnPlain("Could not lock %s\n%s", filePath, e.getMessage());
return new FcState(filePath, null, false);
}
}
@ -70,10 +64,11 @@ public class LockUtil {
} catch (IOException | OverlappingFileLockException e) {
if (tryCount > 0) {
tryCount--;
LOGGER.info("Could not close " + fc + " Will try " + tryCount + " times.");
LogU.warnPlain("Could not close %s. Will try %s times.", fc, tryCount);
return unlockFile(filePath, fc, tryCount);
}
LOGGER.info("Could not unlock " + fc);
LogU.warnPlain("Could not unlock %s", fc);
return new FcState(filePath, null, true);
}
}

@ -4,4 +4,5 @@ collection/books
collection/movies
collection/music
collection/software
collection/tv
collection/youtube

@ -1,11 +1,11 @@
package com.olexyn.ensync.files;
import com.olexyn.ensync.Flow;
import com.olexyn.ensync.LogUtil;
import com.olexyn.ensync.Tools;
import com.olexyn.ensync.artifacts.DataRoot;
import com.olexyn.ensync.artifacts.SyncBundle;
import com.olexyn.ensync.lock.LockUtil;
import com.olexyn.min.log.LogU;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Assert;
@ -20,7 +20,6 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
/**
@ -29,7 +28,6 @@ import java.util.logging.Logger;
*/
public class FifteenTests {
private static final Logger LOGGER = LogUtil.get(FifteenTests.class);
final public static Flow FLOW = new Flow();
@ -48,40 +46,40 @@ public class FifteenTests {
private List<String> createFile(File file) {
if (file.exists()) {
LOGGER.info("TEST can not create existing: " + file.toPath());
LogU.infoPlain("TEST can not create existing: " + file.toPath());
Assert.fail();
}
List<String> stringList = new ArrayList<>();
stringList.add(LocalDateTime.now().format(dateTimeFormatter) + " CREATED");
tools.writeStringListToFile(file.getAbsolutePath(), stringList);
LOGGER.info("TEST CREATE: " + file.toPath());
LogU.infoPlain("TEST CREATE: " + file.toPath());
return stringList;
}
private List<String> modifyFile(File file) {
LOGGER.info("TEST TRY MODIFY: " + file.toPath());
LogU.infoPlain("TEST TRY MODIFY: " + file.toPath());
var fcState = LockUtil.lockFile(file.toPath(), 10);
var stringList = new ArrayList<>(tools.fileToLines(fcState.getFc()));
stringList.add(LocalDateTime.now().format(dateTimeFormatter) + " MODIFIED");
tools.writeStringListToFile(file.getAbsolutePath(), stringList);
LOGGER.info("TEST MODIFY: " + file.toPath());
LogU.infoPlain("TEST MODIFY: " + file.toPath());
LockUtil.unlockFile(fcState, 10);
LOGGER.info("TEST MODIFY UNLOCKED: " + file.toPath());
LogU.infoPlain("TEST MODIFY UNLOCKED: " + file.toPath());
return stringList;
}
private static void deleteFile(File file) {
LOGGER.info("TEST TRY DELETE: " + file.toPath());
LogU.infoPlain("TEST TRY DELETE: " + file.toPath());
var fcState = LockUtil.lockFile(file.toPath(), 10);
try {
Files.delete(file.toPath());
LOGGER.info("TEST DELETE: " + file.toPath());
LogU.infoPlain("TEST DELETE: " + file.toPath());
} catch (IOException e) {
LOGGER.severe("Could not delete file." + file.toPath());
LogU.warnPlain("Could not delete file." + file.toPath());
}
LockUtil.unlockFile(fcState, 10);
LOGGER.info("TEST DELETE UNLOCKED: " + file.toPath());
LogU.infoPlain("TEST DELETE UNLOCKED: " + file.toPath());
}
private void cleanDirs(Path... dirs) {
@ -90,7 +88,7 @@ public class FifteenTests {
FileUtils.deleteDirectory(dir.toFile());
Files.createDirectory(dir);
} catch (IOException e) {
LOGGER.severe("Could not clear dirs. " + dir + e.getMessage());
LogU.warnPlain("Could not clear dirs. " + dir + e.getMessage());
}
}
}

@ -1,21 +1,15 @@
package com.olexyn.ensync.files;
import com.olexyn.ensync.LogUtil;
import com.olexyn.ensync.Tools;
import com.olexyn.ensync.artifacts.SyncDirectory;
import com.olexyn.ensync.lock.LockKeeper;
import com.olexyn.ensync.lock.LockUtil;
import com.olexyn.min.log.LogU;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.logging.Logger;
public class TestFile extends File {
private static final Logger LOGGER = LogUtil.get(TestFile.class);
Tools tools = new Tools();
/**
@ -26,7 +20,7 @@ public class TestFile extends File {
}
public List<String> readContent() {
LOGGER.info("TEST TRY READ: " + toPath());
LogU.infoPlain("TEST TRY READ: " + toPath());
var fcState = LockUtil.lockFile(toPath());
return tools.fileToLines(fcState.getFc());
}

Loading…
Cancel
Save