Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "refactor GitAskPassScript directory generation" #1322

Merged
merged 1 commit into from
May 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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