Skip to content

Commit

Permalink
Tested and fixed issue reported by beddet
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerratar committed Apr 8, 2018
1 parent f206a8a commit 1c2b2be
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 18 deletions.
Binary file modified build/SubSync.exe
Binary file not shown.
7 changes: 5 additions & 2 deletions src/SubSync/Processors/SubSyncMediaWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ public void Stop()

public void SyncAll()
{
this.videoExtensions.SelectMany(y => Directory
.GetFiles(this.input, $"*{y}", SearchOption.AllDirectories))

this.videoExtensions.SelectMany(y =>
new DirectoryInfo(this.input).GetFiles($"*{y}", SearchOption.AllDirectories))
.Select(x => x.FullName)
//Directory.GetFiles(this.input, $"*{y}", SearchOption.AllDirectories))
.ForEach(Sync);
}

Expand Down
18 changes: 11 additions & 7 deletions src/SubSync/Processors/SubSyncWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ public void Dispose() { }

private string Rename(string fileToRename, string newFilaNameWithoutExtension)
{
var directory = new FileInfo(fileToRename).Directory?.FullName ?? "./";
var inFile = new FileInfo(fileToRename);
var directory = inFile.Directory?.FullName ?? "./";
var destFileName = Path.Combine(directory, newFilaNameWithoutExtension + Path.GetExtension(fileToRename));
File.Move(fileToRename, destFileName);
inFile.MoveTo(destFileName);
//File.Move(fileToRename, destFileName);
return destFileName;
}

Expand All @@ -96,15 +98,16 @@ private Task<string> DecompressAsync(string filename)
}
}

private async Task<string> DecompressArchive(string filename, Func<string, IArchive> archiveOpener)
private async Task<string> DecompressArchive(string filename, Func<Stream, IArchive> archiveOpener)
{
var file = new FileInfo(filename);
var targetFile = string.Empty;
try
{
var fileDirectory = file.Directory;
var directory = fileDirectory?.FullName ?? "./";
using (var reader = archiveOpener(filename))
using (var fileReader = file.OpenRead())
using (var reader = archiveOpener(fileReader))
{
foreach (var entry in reader.Entries)
{
Expand All @@ -126,8 +129,9 @@ private async Task<string> DecompressArchive(string filename, Func<string, IArch
dir.Create();
}

var targetFileInfo = new FileInfo(targetFile);
using (var entryStream = entry.OpenEntryStream())
using (var sw = new FileStream(targetFile, FileMode.Create))
using (var sw = targetFileInfo.OpenCreate())//new FileStream(targetFile, FileMode.Create))
{
var read = 0;
var buffer = new byte[4096];
Expand All @@ -154,8 +158,8 @@ private async Task<string> DecompressArchive(string filename, Func<string, IArch

private Task<string> DecompressRarAsync(string filename) => DecompressArchive(filename, x => SharpCompress.Archives.Rar.RarArchive.Open(x));
private Task<string> DecompressZipAsync(string filename) => DecompressArchive(filename, x => SharpCompress.Archives.Zip.ZipArchive.Open(x));
private Task<string> DecompressGZipAsync(string filename) =>DecompressArchive(filename, x => SharpCompress.Archives.GZip.GZipArchive.Open(x));
private Task<string> Decompress7ZipAsync(string filename) =>DecompressArchive(filename, x => SharpCompress.Archives.SevenZip.SevenZipArchive.Open(x));
private Task<string> DecompressGZipAsync(string filename) => DecompressArchive(filename, x => SharpCompress.Archives.GZip.GZipArchive.Open(x));
private Task<string> Decompress7ZipAsync(string filename) => DecompressArchive(filename, x => SharpCompress.Archives.SevenZip.SevenZipArchive.Open(x));
private Task<string> DecompressTarAsync(string filename) => DecompressArchive(filename, x => SharpCompress.Archives.Tar.TarArchive.Open(x));

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down
21 changes: 13 additions & 8 deletions src/SubSync/Proivders/SubsceneSubtitleProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,24 @@ private async Task<string> DownloadFileAsync(string url, string outputDirectory,
filename = newFileName;
}



var outputFile = System.IO.Path.Combine(outputDirectory, filename);
using (var stream = response.GetResponseStream())
using (var output = new FileStream(outputFile, FileMode.Create))
{
int read = 0;
var buffer = new byte[4096];

while ((read = await stream.ReadAsync(buffer, 0, buffer.Length)) != 0)
var file = new ZetaLongPaths.ZlpFileInfo(outputFile);
using (var output = file.OpenCreate())
{
await output.WriteAsync(buffer, 0, read);
}
int read = 0;
var buffer = new byte[4096];

while ((read = await stream.ReadAsync(buffer, 0, buffer.Length)) != 0)
{
await output.WriteAsync(buffer, 0, read);
}

return outputFile;
return outputFile;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/SubSync/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.*")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyFileVersion("0.1.2.0")]

0 comments on commit 1c2b2be

Please sign in to comment.