@ -126,23 +126,7 @@ public class TransportAmazonS3 extends HttpTransport implements WalkTransport {
throws NotSupportedException {
throws NotSupportedException {
super ( local , uri ) ;
super ( local , uri ) ;
Properties props = null ;
s3 = new AmazonS3 ( loadProperties ( ) ) ;
File propsFile = new File ( local . getDirectory ( ) , uri . getUser ( ) ) ;
if ( ! propsFile . isFile ( ) )
propsFile = new File ( local . getFS ( ) . userHome ( ) , uri . getUser ( ) ) ;
if ( propsFile . isFile ( ) ) {
try {
props = AmazonS3 . properties ( propsFile ) ;
} catch ( IOException e ) {
throw new NotSupportedException ( MessageFormat . format ( JGitText . get ( ) . cannotReadFile , propsFile ) , e ) ;
}
} else {
props = new Properties ( ) ;
props . setProperty ( "accesskey" , uri . getUser ( ) ) ;
props . setProperty ( "secretkey" , uri . getPass ( ) ) ;
}
s3 = new AmazonS3 ( props ) ;
bucket = uri . getHost ( ) ;
bucket = uri . getHost ( ) ;
String p = uri . getPath ( ) ;
String p = uri . getPath ( ) ;
@ -153,6 +137,33 @@ public class TransportAmazonS3 extends HttpTransport implements WalkTransport {
keyPrefix = p ;
keyPrefix = p ;
}
}
private Properties loadProperties ( ) throws NotSupportedException {
if ( local . getDirectory ( ) ! = null ) {
File propsFile = new File ( local . getDirectory ( ) , uri . getUser ( ) ) ;
if ( propsFile . isFile ( ) )
return loadPropertiesFile ( propsFile ) ;
}
File propsFile = new File ( local . getFS ( ) . userHome ( ) , uri . getUser ( ) ) ;
if ( propsFile . isFile ( ) )
return loadPropertiesFile ( propsFile ) ;
Properties props = new Properties ( ) ;
props . setProperty ( "accesskey" , uri . getUser ( ) ) ;
props . setProperty ( "secretkey" , uri . getPass ( ) ) ;
return props ;
}
private static Properties loadPropertiesFile ( File propsFile )
throws NotSupportedException {
try {
return AmazonS3 . properties ( propsFile ) ;
} catch ( IOException e ) {
throw new NotSupportedException ( MessageFormat . format (
JGitText . get ( ) . cannotReadFile , propsFile ) , e ) ;
}
}
@Override
@Override
public FetchConnection openFetch ( ) throws TransportException {
public FetchConnection openFetch ( ) throws TransportException {
final DatabaseS3 c = new DatabaseS3 ( bucket , keyPrefix + "/objects" ) ;
final DatabaseS3 c = new DatabaseS3 ( bucket , keyPrefix + "/objects" ) ;