Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
BZ-1045537: this looks like a JGit issue, this fix is a woraround tha…
Browse files Browse the repository at this point in the history
…t forces clean internal cache. as this issues is windows only, the code just forces the clean if OS is windows.
  • Loading branch information
porcelli committed Feb 27, 2014
1 parent 65de81f commit 01e65ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Expand Up @@ -53,6 +53,8 @@
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.file.WindowCache;
import org.eclipse.jgit.storage.file.WindowCacheConfig;
import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.PostReceiveHook;
import org.eclipse.jgit.transport.PreReceiveHook;
Expand Down Expand Up @@ -984,12 +986,14 @@ public void delete( final Path path,
private boolean deleteRepo( final FileSystem fileSystem ) {
final File gitDir = ( (JGitFileSystem) fileSystem ).gitRepo().getRepository().getDirectory();
fileSystem.close();
fileSystem.dispose();

try {
if ( System.getProperty( "os.name" ).toLowerCase().contains( "windows" ) ) {
//this operation forces a cache clean freeing any lock -> windows only issue!
WindowCache.reconfigure( new WindowCacheConfig() );
}
FileUtils.delete( gitDir, FileUtils.RECURSIVE | FileUtils.RETRY );
closedFileSystems.remove( fileSystem );
fileSystems.remove( ( (JGitFileSystem) fileSystem ).id() );
repoIndex.remove( ( (JGitFileSystem) fileSystem ).gitRepo().getRepository() );
return true;
} catch ( java.io.IOException e ) {
throw new IOException( e );
Expand Down
Expand Up @@ -16,6 +16,7 @@

package org.uberfire.java.nio.fs.jgit.util;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
Expand Down Expand Up @@ -142,12 +143,7 @@ public static InputStream resolveInputStream( final Git git,
tw.enterSubtree();
continue;
}
final ObjectId entid = tw.getObjectId( 0 );
final FileMode entmode = tw.getFileMode( 0 );
final RevObject ro = rw.lookupAny( entid, entmode.getObjectType() );
rw.parseBody( ro );
final ObjectLoader ldr = git.getRepository().open( ro.getId(), Constants.OBJ_BLOB );
return ldr.openStream();
return new ByteArrayInputStream( git.getRepository().open( tw.getObjectId( 0 ), Constants.OBJ_BLOB ).getBytes() );
}
} catch ( final Throwable t ) {
throw new NoSuchFileException( "Can't find '" + gitPath + "' in tree '" + treeRef + "'" );
Expand Down

0 comments on commit 01e65ad

Please sign in to comment.