Skip to content

Commit c73a5aa

Browse files
authored
Merge pull request #1355 from jdcasey/master
Restore readonly status on CacheOnlyLocation if it gets overridden.
2 parents e4ef333 + 3f28384 commit c73a5aa

1 file changed

Lines changed: 32 additions & 10 deletions

File tree

core/src/main/java/org/commonjava/indy/core/content/DefaultDownloadManager.java

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -623,14 +623,25 @@ else if ( !deploy.isAllowReleases() )
623623
try
624624
{
625625
KeyedLocation loc = LocationUtils.toLocation( store );
626-
if ( isIgnoreReadonly( eventMetadata ) && loc instanceof CacheOnlyLocation )
626+
boolean resetReadonly = ( !loc.allowsStoring() && isIgnoreReadonly( eventMetadata ) && loc instanceof CacheOnlyLocation );
627+
try
628+
{
629+
if ( resetReadonly )
630+
{
631+
( (CacheOnlyLocation) loc ).setReadonly( false );
632+
}
633+
final ConcreteResource resource = new ConcreteResource( loc, path );
634+
Transfer txfr = transfers.store( resource, stream, eventMetadata );
635+
nfc.clearMissing( resource );
636+
return txfr;
637+
}
638+
finally
627639
{
628-
( (CacheOnlyLocation) loc ).setReadonly( false );
640+
if ( resetReadonly )
641+
{
642+
( (CacheOnlyLocation) loc ).setReadonly( true );
643+
}
629644
}
630-
final ConcreteResource resource = new ConcreteResource( loc, path );
631-
Transfer txfr = transfers.store( resource, stream, eventMetadata );
632-
nfc.clearMissing( resource );
633-
return txfr;
634645
}
635646
catch ( final BadGatewayException e )
636647
{
@@ -1017,12 +1028,23 @@ private Boolean doDelete( final Transfer item, final EventMetadata eventMetadata
10171028
try
10181029
{
10191030
Location loc = item.getLocation();
1020-
if ( isIgnoreReadonly( eventMetadata ) && loc instanceof CacheOnlyLocation )
1031+
boolean resetReadonly = ( !loc.allowsStoring() && isIgnoreReadonly( eventMetadata ) && loc instanceof CacheOnlyLocation );
1032+
try
1033+
{
1034+
if ( resetReadonly )
1035+
{
1036+
( (CacheOnlyLocation) loc ).setReadonly( false );
1037+
}
1038+
final ConcreteResource resource = new ConcreteResource( loc, item.getPath() );
1039+
transfers.delete( resource, eventMetadata );
1040+
}
1041+
finally
10211042
{
1022-
( (CacheOnlyLocation) loc ).setReadonly( false );
1043+
if ( resetReadonly )
1044+
{
1045+
( (CacheOnlyLocation) loc ).setReadonly( true );
1046+
}
10231047
}
1024-
final ConcreteResource resource = new ConcreteResource( loc, item.getPath() );
1025-
transfers.delete( resource, eventMetadata );
10261048
}
10271049
catch ( final TransferException e )
10281050
{

0 commit comments

Comments
 (0)