Skip to content

Commit

Permalink
copy
Browse files Browse the repository at this point in the history
rename file
disable rename collection (for now at least)
  • Loading branch information
labkey-matthewb committed Nov 4, 2024
1 parent 98f25e1 commit 51ad251
Show file tree
Hide file tree
Showing 14 changed files with 391 additions and 157 deletions.
4 changes: 3 additions & 1 deletion api/src/org/labkey/api/data/TempTableTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,13 @@ private void untrack()

synchronized(createdTableNames)
{
createdTableNames.remove(qualifiedName);
var ttt = createdTableNames.remove(qualifiedName);
appendToLog("-" + schemaName + "\t" + tableName + "\n");

if (createdTableNames.isEmpty() || System.currentTimeMillis() > lastSync + CacheManager.DAY)
synchronizeLog(false);

ttt.clear();
}
}

Expand Down
39 changes: 39 additions & 0 deletions api/src/org/labkey/api/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,22 @@ public static boolean mkdirs(File file, boolean checkFileName) throws IOExceptio
return file.mkdirs();
}

public static boolean mkdirs(FileLike file, boolean checkFileName) throws IOException
{
FileLike parent = file;
var ret = false;
while (!Files.exists(parent.toNioPathForWrite()))
{
ret = true;
if (checkFileName)
checkAllowedFileName(parent.getName());
parent = parent.getParent();
}
//noinspection SSBasedInspection
file.mkdirs();
return ret;
}


public static Path createDirectory(Path path) throws IOException
{
Expand Down Expand Up @@ -435,6 +451,13 @@ public static Path createDirectories(Path path, boolean checkFileName) throws IO
}


public static boolean renameTo(FileLike from, FileLike to)
{
// TODO FileLike.renameTo()
return toFileForRead(from).renameTo(toFileForWrite(to));
}


public static boolean createNewFile(File file) throws IOException
{
return createNewFile(file, AppProps.getInstance().isInvalidFilenameBlocked());
Expand All @@ -450,6 +473,16 @@ public static boolean createNewFile(File file, boolean checkFileName) throws IOE
}


public static boolean createNewFile(FileLike file, boolean checkFileName) throws IOException
{
if (checkFileName)
checkAllowedFileName(file.getName());
var ret = !file.exists();
file.createFile();
return ret;
}


public static Path createFile(Path path, FileAttribute<?>... attrs) throws IOException
{
return createFile(path, AppProps.getInstance().isInvalidFilenameBlocked(), attrs);
Expand Down Expand Up @@ -591,6 +624,12 @@ public static boolean hasCloudScheme(String url)
}


public static boolean hasCloudScheme(FileLike filelike)
{
return "s3".equals(filelike.getFileSystem().getScheme());
}


public static String getAbsolutePath(Path path)
{
if (!FileUtil.hasCloudScheme(path))
Expand Down
Loading

0 comments on commit 51ad251

Please sign in to comment.