Skip to content

Commit

Permalink
feat: when saving offline package, skip team dirs
Browse files Browse the repository at this point in the history
directories named `.repositories`, `.git` and `.snv` are always skipped.
  • Loading branch information
briacp committed Jun 3, 2023
1 parent 52c72bf commit d4b17d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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/
11 changes: 9 additions & 2 deletions src/main/java/net/briac/omegat/plugin/omt/ManageOMTPackage.java
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,9 @@ private static final int addZipDir(final ZipOutputStream out, final Path root, f
final ProjectProperties props, DirectoryStream.Filter<Path> filter) throws IOException
{
int addedFiles = 0;

boolean skipRepositories = Boolean.parseBoolean(pluginProps.getProperty(PROPERTY_PACK_OFFLINE, FALSE));

try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, filter)) {
for (Path child : stream) {
final Path childPath = child.getFileName();
Expand All @@ -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.
Expand All @@ -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) {
Expand Down

0 comments on commit d4b17d4

Please sign in to comment.