Skip to content

Commit

Permalink
Revert "refactor GitAskPassScript directory generation" (#1322)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalii Parfonov committed May 20, 2016
1 parent 7b6e84f commit a8c8bb9
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
*******************************************************************************/
package org.eclipse.che.git.impl.nativegit;

import org.eclipse.che.api.git.GitException;
import org.eclipse.che.api.git.UserCredential;
import org.eclipse.che.commons.env.EnvironmentContext;
import org.eclipse.che.commons.lang.IoUtil;
import org.eclipse.che.commons.lang.NameGenerator;
import org.eclipse.che.api.git.GitException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -31,7 +32,6 @@ public class GitAskPassScript {
private static final String GIT_ASK_PASS_SCRIPT_TEMPLATE = "META-INF/NativeGitAskPassTemplate";
private static final String GIT_ASK_PASS_SCRIPT = "ask_pass";
private String gitAskPassTemplate;
private File askScriptDirectory;

private static final Logger LOG = LoggerFactory.getLogger(GitAskPassScript.class);

Expand All @@ -47,8 +47,8 @@ public GitAskPassScript() {
* @return stored script
*/
public File build(UserCredential credentials) throws GitException {
askScriptDirectory = new File(System.getProperty("java.io.tmpdir") + NameGenerator.generate("", 8));

File askScriptDirectory = new File(System.getProperty("java.io.tmpdir")
+ "/" + EnvironmentContext.getCurrent().getSubject().getUserName());
if (!askScriptDirectory.exists()) {
askScriptDirectory.mkdirs();
}
Expand All @@ -71,7 +71,9 @@ public File build(UserCredential credentials) throws GitException {

public void remove() {

if (askScriptDirectory != null && askScriptDirectory.exists()) {
File askScriptDirectory = new File(System.getProperty("java.io.tmpdir")
+ "/" + EnvironmentContext.getCurrent().getSubject().getUserName());
if (askScriptDirectory.exists()) {
if (!IoUtil.deleteRecursive(askScriptDirectory))
LOG.warn("Ask-pass script deletion failed.");
}
Expand Down

0 comments on commit a8c8bb9

Please sign in to comment.