kopia lustrzana https://github.com/jortage/poolmgr
Remove no-longer-needed BlobAccess hack, print SQL exceptions, 4s 202
rodzic
0ee3368f9b
commit
b2af320231
|
@ -42,7 +42,7 @@ public class MastodonHackHandler extends HandlerWrapper {
|
|||
response.sendError(202);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}, 500, TimeUnit.MILLISECONDS);
|
||||
}, 4000, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
super.handle(target, baseRequest, request, response);
|
||||
if (shortCircuit != null) shortCircuit.cancel(false);
|
||||
|
|
|
@ -37,6 +37,11 @@ public class Queries {
|
|||
return sfn;
|
||||
}
|
||||
|
||||
private static void onSQLException(SQLException e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("Got SQL exception!");
|
||||
}
|
||||
|
||||
public static HashCode getMap(DataSource dataSource, String identity, String name) {
|
||||
name = toSFN(name);
|
||||
try (Connection c = dataSource.getConnection()) {
|
||||
|
@ -52,6 +57,7 @@ public class Queries {
|
|||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
onSQLException(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +73,7 @@ public class Queries {
|
|||
ps.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
onSQLException(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +87,7 @@ public class Queries {
|
|||
return ps.executeUpdate() > 0;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
onSQLException(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@ -97,6 +105,7 @@ public class Queries {
|
|||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
onSQLException(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@ -110,6 +119,7 @@ public class Queries {
|
|||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
onSQLException(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@ -122,6 +132,7 @@ public class Queries {
|
|||
ps.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
onSQLException(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@ -144,6 +155,7 @@ public class Queries {
|
|||
ps.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
onSQLException(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@ -155,6 +167,7 @@ public class Queries {
|
|||
ps.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
onSQLException(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@ -170,6 +183,7 @@ public class Queries {
|
|||
ps.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
onSQLException(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@ -189,6 +203,7 @@ public class Queries {
|
|||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
onSQLException(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@ -206,6 +221,7 @@ public class Queries {
|
|||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
onSQLException(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@ -217,6 +233,7 @@ public class Queries {
|
|||
ps.executeUpdate();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
onSQLException(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.eclipse.jetty.server.Request;
|
|||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.jclouds.blobstore.BlobStore;
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.domain.BlobAccess;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
|
@ -69,10 +68,6 @@ public final class RedirHandler extends AbstractHandler {
|
|||
response.setHeader("Jortage-Waited", "true");
|
||||
}
|
||||
String hash = Queries.getMap(Poolmgr.dataSource, identity, name).toString();
|
||||
BlobAccess ba = Poolmgr.backingBlobStore.getBlobAccess(Poolmgr.bucket, Poolmgr.hashToPath(hash));
|
||||
if (ba != BlobAccess.PUBLIC_READ) {
|
||||
Poolmgr.backingBlobStore.setBlobAccess(Poolmgr.bucket, Poolmgr.hashToPath(hash), BlobAccess.PUBLIC_READ);
|
||||
}
|
||||
response.setHeader("Cache-Control", "public");
|
||||
response.setHeader("Location", Poolmgr.publicHost+"/"+Poolmgr.hashToPath(hash));
|
||||
response.setStatus(301);
|
||||
|
|
Ładowanie…
Reference in New Issue