Merge branch 'ref/path-lib' into 'master'

Ref: do not re-invent the wheel, use existing lib

See merge request sheepitrenderfarm/client!357
This commit is contained in:
Sheepit Renderfarm
2025-01-11 10:39:15 +00:00
2 changed files with 7 additions and 4 deletions

View File

@@ -46,6 +46,7 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.12.+' implementation 'com.squareup.okhttp3:okhttp:4.12.+'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:4.12.+' implementation 'com.squareup.okhttp3:okhttp-urlconnection:4.12.+'
implementation 'org.slf4j:slf4j-nop:1.7.36' implementation 'org.slf4j:slf4j-nop:1.7.36'
implementation 'commons-io:commons-io:2.11.0'
} }
application { application {

View File

@@ -23,6 +23,7 @@ import com.sheepit.client.logger.Log;
import com.sheepit.client.datamodel.server.Chunk; import com.sheepit.client.datamodel.server.Chunk;
import com.sheepit.client.utils.Utils; import com.sheepit.client.utils.Utils;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.apache.commons.io.FilenameUtils;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -203,9 +204,9 @@ public class DirectoryManager {
for (File file : files) { for (File file : files) {
if (file.isFile()) { if (file.isFile()) {
try { try {
String extension = file.getName().substring(file.getName().lastIndexOf('.')).toLowerCase(); String extension = FilenameUtils.getExtension(file.getName()).toLowerCase();
String name = file.getName().substring(0, file.getName().length() - 1 * extension.length()); String name = FilenameUtils.removeExtension(file.getName());
if (".wool".equals(extension)) { if ("wool".equals(extension)) {
// check if the md5 of the file is ok // check if the md5 of the file is ok
String md5_local = Utils.md5(file.getAbsolutePath()); String md5_local = Utils.md5(file.getAbsolutePath());
@@ -214,10 +215,11 @@ public class DirectoryManager {
} }
} }
} }
catch (StringIndexOutOfBoundsException e) { // because the file does not have an . his path catch (IllegalArgumentException e) { // because the file does not have an . his path
} }
} }
} }
return files_local; return files_local;
} }