From d4b17d4fccbeaea092a1407c5f7266f278541810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Briac=20Pilpr=C3=A9?= Date: Sat, 3 Jun 2023 21:00:38 +0200 Subject: [PATCH] feat: when saving offline package, skip team dirs directories named `.repositories`, `.git` and `.snv` are always skipped. --- gradle.properties | 2 +- .../net/briac/omegat/plugin/omt/ManageOMTPackage.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 490deb9..cb40bba 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,5 +3,5 @@ plugin.name=OMT Package Plugin plugin.author=Briac Pilpr\u00e9 plugin.description=https://github.com/briacp/plugin-omt-package plugin.link=https://github.com/briacp/plugin-omt-package -version=1.7.0 +version=1.7.1 omegatPluginDir=C:/Users/briac/AppData/Roaming/OmegaT/plugins/ diff --git a/src/main/java/net/briac/omegat/plugin/omt/ManageOMTPackage.java b/src/main/java/net/briac/omegat/plugin/omt/ManageOMTPackage.java index 1ba4177..a5abab0 100644 --- a/src/main/java/net/briac/omegat/plugin/omt/ManageOMTPackage.java +++ b/src/main/java/net/briac/omegat/plugin/omt/ManageOMTPackage.java @@ -726,6 +726,9 @@ private static final int addZipDir(final ZipOutputStream out, final Path root, f final ProjectProperties props, DirectoryStream.Filter filter) throws IOException { int addedFiles = 0; + + boolean skipRepositories = Boolean.parseBoolean(pluginProps.getProperty(PROPERTY_PACK_OFFLINE, FALSE)); + try (DirectoryStream stream = Files.newDirectoryStream(dir, filter)) { for (Path child : stream) { final Path childPath = child.getFileName(); @@ -737,6 +740,11 @@ private static final int addZipDir(final ZipOutputStream out, final Path root, f continue; } + if (skipRepositories && (childPath.endsWith(".repositories") || childPath.endsWith(".git") + || childPath.endsWith(".svn"))) { + continue; + } + if (root == null && childPath.endsWith(OConsts.FILE_PROJECT)) { // Special case - when a project is opened, the project file is locked and // can't be copied directly. To avoid this, we make a temp copy. @@ -745,8 +753,7 @@ private static final int addZipDir(final ZipOutputStream out, final Path root, f File tmpProjectFile = File.createTempFile("omt", OConsts.BACKUP_EXTENSION, props.getProjectRootDir()); - boolean skipRepositories = Boolean.parseBoolean(pluginProps.getProperty(PROPERTY_PACK_OFFLINE, FALSE)); - + try { ProjectFileStorage.writeProjectFile(props, tmpProjectFile, skipRepositories); } catch (Exception e) {