mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Make sure to set the content type on uploaded files
This commit is contained in:
parent
e6f5053a48
commit
8beb0b6288
@ -80,7 +80,9 @@ public class WabbajackCDNDownloader : ADownloader<WabbajackCDN>, IUrlDownloader,
|
|||||||
var definition = (await GetDefinition(state, token))!;
|
var definition = (await GetDefinition(state, token))!;
|
||||||
await using var fs = destination.Open(FileMode.Create, FileAccess.Write, FileShare.None);
|
await using var fs = destination.Open(FileMode.Create, FileAccess.Write, FileShare.None);
|
||||||
|
|
||||||
await definition.Parts.PMapAll(async part =>
|
await definition.Parts.PMapAll<PartDefinition, (MemoryStream, PartDefinition)>(async part =>
|
||||||
|
{
|
||||||
|
return await CircuitBreaker.WithAutoRetryAllAsync<(MemoryStream, PartDefinition)>(_logger, async () =>
|
||||||
{
|
{
|
||||||
using var partJob = await _limiter.Begin(
|
using var partJob = await _limiter.Begin(
|
||||||
$"Downloading {definition.MungedName} ({part.Index}/{definition.Size})",
|
$"Downloading {definition.MungedName} ({part.Index}/{definition.Size})",
|
||||||
@ -107,6 +109,7 @@ public class WabbajackCDNDownloader : ADownloader<WabbajackCDN>, IUrlDownloader,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (ms, part);
|
return (ms, part);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}).Do(async rec =>
|
}).Do(async rec =>
|
||||||
|
@ -29,6 +29,7 @@ public class AuthorFiles
|
|||||||
private HashSet<RelativePath> _mangledNames;
|
private HashSet<RelativePath> _mangledNames;
|
||||||
private readonly RecyclableMemoryStreamManager _streamPool;
|
private readonly RecyclableMemoryStreamManager _streamPool;
|
||||||
private readonly HttpClient _httpClient;
|
private readonly HttpClient _httpClient;
|
||||||
|
private readonly AbsolutePath _cacheFile;
|
||||||
|
|
||||||
private Uri _baseUri => new($"https://r2.wabbajack.org/");
|
private Uri _baseUri => new($"https://r2.wabbajack.org/");
|
||||||
|
|
||||||
@ -43,25 +44,25 @@ public class AuthorFiles
|
|||||||
_bucketName = settings.AuthoredFilesS3.BucketName;
|
_bucketName = settings.AuthoredFilesS3.BucketName;
|
||||||
_ = PrimeCache();
|
_ = PrimeCache();
|
||||||
_streamPool = new RecyclableMemoryStreamManager();
|
_streamPool = new RecyclableMemoryStreamManager();
|
||||||
|
_cacheFile = _settings.AuthoredFilesS3.BucketCacheFile.ToAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task PrimeCache()
|
private async Task PrimeCache()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var cacheFile = _settings.AuthoredFilesS3.BucketCacheFile.ToAbsolutePath();
|
if (!_cacheFile.FileExists())
|
||||||
if (!cacheFile.FileExists())
|
|
||||||
{
|
{
|
||||||
var allObjects = await AllObjects().ToArrayAsync();
|
var allObjects = await AllObjects().ToArrayAsync();
|
||||||
foreach (var obje in allObjects)
|
foreach (var obje in allObjects)
|
||||||
{
|
{
|
||||||
_allObjects.TryAdd(obje.Key.ToRelativePath(), obje.LastModified.ToFileTimeUtc());
|
_allObjects.TryAdd(obje.Key.ToRelativePath(), obje.LastModified.ToFileTimeUtc());
|
||||||
}
|
}
|
||||||
SaveBucketCacheFile(cacheFile);
|
SaveBucketCacheFile(_cacheFile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LoadBucketCacheFile(cacheFile);
|
LoadBucketCacheFile(_cacheFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -183,7 +184,8 @@ public class AuthorFiles
|
|||||||
BucketName = _bucketName,
|
BucketName = _bucketName,
|
||||||
Key = mungedName.ToRelativePath().Combine("parts", part.ToString()).ToString().Replace("\\", "/"),
|
Key = mungedName.ToRelativePath().Combine("parts", part.ToString()).ToString().Replace("\\", "/"),
|
||||||
InputStream = ms,
|
InputStream = ms,
|
||||||
DisablePayloadSigning = true
|
DisablePayloadSigning = true,
|
||||||
|
ContentType = "application/octet-stream"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +203,8 @@ public class AuthorFiles
|
|||||||
BucketName = _bucketName,
|
BucketName = _bucketName,
|
||||||
Key = definition.MungedName.ToRelativePath().Combine("definition.json.gz").ToString().Replace("\\", "/"),
|
Key = definition.MungedName.ToRelativePath().Combine("definition.json.gz").ToString().Replace("\\", "/"),
|
||||||
InputStream = ms,
|
InputStream = ms,
|
||||||
DisablePayloadSigning = true
|
DisablePayloadSigning = true,
|
||||||
|
ContentType = "application/octet-stream"
|
||||||
});
|
});
|
||||||
_fileCache.TryAdd(definition.MungedName, new FileDefinitionMetadata
|
_fileCache.TryAdd(definition.MungedName, new FileDefinitionMetadata
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user