Hop can corrupt pipeline or workflow files
package org.apache.hop.core.vfs;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.vfs2.*;
+import org.apache.commons.vfs2.CacheStrategy;
+import org.apache.commons.vfs2.FileContent;
+import org.apache.commons.vfs2.FileName;
+import org.apache.commons.vfs2.FileObject;
+import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.cache.SoftRefFilesCache;
import org.apache.commons.vfs2.impl.DefaultFileReplicator;
import org.apache.commons.vfs2.impl.DefaultFileSystemManager;
@@ -34,7 +38,12 @@ import org.apache.hop.core.vfs.plugin.IVfs;
import org.apache.hop.core.vfs.plugin.VfsPluginType;
import org.apache.hop.i18n.BaseMessages;
-import java.io.*;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@@ -282,6 +291,14 @@ public class HopVfs {
}
}
try {
+ // Temporary work-around for VFS-807 bug (can be removed after 2.9.0)
+ //
+ if (fileObject.exists() && !append) {
+ // Content was not removed at the trailing end of the file
+ // Se we're going to delete the file first in this scenario
+ //
+ fileObject.delete();
+ }
fileObject.createFile();
FileContent content = fileObject.getContent();
return content.getOutputStream(append);
