Search in sources :

Example 1 with FileUtils

use of org.exist.util.FileUtils in project exist by eXist-db.

the class JournalTest method getFiles.

@Test
public void getFiles() throws IOException {
    List<String> input = Arrays.asList(new String[] { "0000000001.log" });
    Path mockJournalDir = createTempDirWithFiles(input);
    List<String> actual = Journal.getFiles(mockJournalDir).map(FileUtils::fileName).collect(Collectors.toList());
    assertEquals(input, actual);
    input = Arrays.asList(new String[] { "0000000001.log", "0000000002.log", "000000000a.log" });
    mockJournalDir = createTempDirWithFiles(input);
    actual = Journal.getFiles(mockJournalDir).map(FileUtils::fileName).collect(Collectors.toList());
    Collections.sort(input);
    Collections.sort(actual);
    assertEquals(input, actual);
    input = Arrays.asList(new String[] { "0000000001.log", "0000000001.log" + Journal.BAK_FILE_SUFFIX, "0000000001_index.log", "journal.lck" });
    mockJournalDir = createTempDirWithFiles(input);
    actual = Journal.getFiles(mockJournalDir).map(FileUtils::fileName).collect(Collectors.toList());
    assertEquals(Arrays.asList(new String[] { "0000000001.log" }), actual);
}
Also used : Path(java.nio.file.Path) FileUtils(org.exist.util.FileUtils) Test(org.junit.Test)

Example 2 with FileUtils

use of org.exist.util.FileUtils in project exist by eXist-db.

the class LuceneIndex method remove.

@Override
public void remove() throws DBException {
    close();
    Path dir = getDataDir().resolve(getDirName());
    try (Stream<Path> stream = Files.list(dir)) {
        stream.forEach(FileUtils::deleteQuietly);
    } catch (Exception e) {
        // never abort at this point, so recovery can continue
        LOG.warn(e.getMessage(), e);
    }
}
Also used : Path(java.nio.file.Path) FileUtils(org.exist.util.FileUtils) DBException(org.exist.storage.btree.DBException) IOException(java.io.IOException) DatabaseConfigurationException(org.exist.util.DatabaseConfigurationException) XPathException(org.exist.xquery.XPathException)

Aggregations

Path (java.nio.file.Path)2 FileUtils (org.exist.util.FileUtils)2 IOException (java.io.IOException)1 DBException (org.exist.storage.btree.DBException)1 DatabaseConfigurationException (org.exist.util.DatabaseConfigurationException)1 XPathException (org.exist.xquery.XPathException)1 Test (org.junit.Test)1