Skip to content

Commit

Permalink
ensure languages order
Browse files Browse the repository at this point in the history
  • Loading branch information
rafdulaf committed Apr 24, 2024
1 parent a19eb56 commit 4f4b34f
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
Expand All @@ -19,10 +19,14 @@ public class GenerateSWListingFiles
{
private final static Set<String> EXCEPTIONS = Set.of(".git", "bin", "tools");

private final static Set<String> LANGUAGES = Set.of("en", "fr", "it");
private final static Set<String> LANGUAGES = new LinkedHashSet<>();

public static void main(String[] args) throws IOException
{
LANGUAGES.add("en");
LANGUAGES.add("fr");
LANGUAGES.add("it");

Path root = Path.of(args[0]);

Files.list(root)
Expand All @@ -35,7 +39,7 @@ public static void main(String[] args) throws IOException

private static void _createFiles(Path root, String application)
{
Map<String, Long> size = new HashMap<>();
Map<String, Long> size = new LinkedHashMap<>();
LANGUAGES.stream().forEach(lang -> size.put(lang, 0L));

try
Expand Down Expand Up @@ -73,12 +77,12 @@ private static Set<String> _listFile(String rootPath, Path directory, Map<String

final Set<String> languages = LANGUAGES;

Files.walkFileTree(directory, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<Path>() {
Files.walkFileTree(directory, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException
{
if (Files.isRegularFile(file) // Not caching folders
&& !file.getFileName().toString().toLowerCase().endsWith("_hd.webp")) // Not caching HS images
&& !file.getFileName().toString().toLowerCase().endsWith("_hd.webp")) // Not caching HS images
{
long fileSize = Files.size(file);
boolean onlyOneLanguage = false;
Expand Down

0 comments on commit 4f4b34f

Please sign in to comment.