aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-07-07 18:04:46 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-07-07 18:04:46 -0400
commit24d91d9363ec909688c571f133db4ebf0fde7f86 (patch)
tree06798c70dd8bdc64ecfad339394ab9363978bd51
parent36f0d495d237c6f17486a10f04d43c1f8c599951 (diff)
update image inheritance
-rw-r--r--Emby.Server.Implementations/Dto/DtoService.cs2
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs17
-rw-r--r--Emby.Server.Implementations/Updates/InstallationManager.cs2
-rw-r--r--MediaBrowser.Api/EnvironmentService.cs58
4 files changed, 61 insertions, 18 deletions
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs
index 9767de9e0..2933a9f22 100644
--- a/Emby.Server.Implementations/Dto/DtoService.cs
+++ b/Emby.Server.Implementations/Dto/DtoService.cs
@@ -1539,7 +1539,7 @@ namespace Emby.Server.Implementations.Dto
dto.ParentArtImageTag = GetImageCacheTag(parent, image);
}
}
- if (thumbLimit > 0 && !dto.HasThumb && (dto.ParentThumbItemId == null || parent is Series))
+ if (thumbLimit > 0 && !dto.HasThumb && (dto.ParentThumbItemId == null || parent is Series) && !(parent is ICollectionFolder) && !(parent is UserView))
{
var image = allImages.FirstOrDefault(i => i.Type == ImageType.Thumb);
diff --git a/Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs b/Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs
index a41e21a4b..52bd0a504 100644
--- a/Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/SystemUpdateTask.cs
@@ -68,23 +68,14 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <returns>Task.</returns>
public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
{
- EventHandler<double> innerProgressHandler = (sender, e) => progress.Report(e * .1);
-
// Create a progress object for the update check
- var innerProgress = new SimpleProgress<double>();
- innerProgress.ProgressChanged += innerProgressHandler;
-
- var updateInfo = await _appHost.CheckForApplicationUpdate(cancellationToken, innerProgress).ConfigureAwait(false);
-
- // Release the event handler
- innerProgress.ProgressChanged -= innerProgressHandler;
+ var updateInfo = await _appHost.CheckForApplicationUpdate(cancellationToken, new SimpleProgress<double>()).ConfigureAwait(false);
progress.Report(10);
if (!updateInfo.IsUpdateAvailable)
{
Logger.Debug("No application update available.");
- progress.Report(100);
return;
}
@@ -96,9 +87,9 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
Logger.Info("Update Revision {0} available. Updating...", updateInfo.AvailableVersion);
- innerProgressHandler = (sender, e) => progress.Report(e * .9 + .1);
+ EventHandler<double> innerProgressHandler = (sender, e) => progress.Report(e * .9 + .1);
- innerProgress = new SimpleProgress<double>();
+ var innerProgress = new SimpleProgress<double>();
innerProgress.ProgressChanged += innerProgressHandler;
await _appHost.UpdateApplication(updateInfo.Package, cancellationToken, innerProgress).ConfigureAwait(false);
@@ -110,8 +101,6 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
Logger.Info("A new version of " + _appHost.Name + " is available.");
}
-
- progress.Report(100);
}
/// <summary>
diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs
index 717416da1..6e37c1dc1 100644
--- a/Emby.Server.Implementations/Updates/InstallationManager.cs
+++ b/Emby.Server.Implementations/Updates/InstallationManager.cs
@@ -513,8 +513,6 @@ namespace Emby.Server.Implementations.Updates
CurrentInstallations.Remove(tuple);
}
- progress.Report(100);
-
CompletedInstallationsInternal.Add(installationInfo);
EventHelper.FireEventIfNotNull(PackageInstallationCompleted, this, installationEventArgs, _logger);
diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.cs
index c4cb0cb1d..9764a71db 100644
--- a/MediaBrowser.Api/EnvironmentService.cs
+++ b/MediaBrowser.Api/EnvironmentService.cs
@@ -50,6 +50,20 @@ namespace MediaBrowser.Api
}
}
+ [Route("/Environment/ValidatePath", "POST", Summary = "Gets the contents of a given directory in the file system")]
+ public class ValidatePath
+ {
+ /// <summary>
+ /// Gets or sets the path.
+ /// </summary>
+ /// <value>The path.</value>
+ [ApiMember(Name = "Path", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
+ public string Path { get; set; }
+
+ public bool ValidateWriteable { get; set; }
+ public bool? IsFile { get; set; }
+ }
+
[Route("/Environment/NetworkShares", "GET", Summary = "Gets shares from a network device")]
public class GetNetworkShares : IReturn<List<FileSystemEntryInfo>>
{
@@ -112,7 +126,7 @@ namespace MediaBrowser.Api
/// The _network manager
/// </summary>
private readonly INetworkManager _networkManager;
- private IFileSystem _fileSystem;
+ private readonly IFileSystem _fileSystem;
/// <summary>
/// Initializes a new instance of the <see cref="EnvironmentService" /> class.
@@ -129,6 +143,48 @@ namespace MediaBrowser.Api
_fileSystem = fileSystem;
}
+ public void Post(ValidatePath request)
+ {
+ if (request.IsFile.HasValue)
+ {
+ if (request.IsFile.Value)
+ {
+ if (!_fileSystem.FileExists(request.Path))
+ {
+ throw new FileNotFoundException("File not found", request.Path);
+ }
+ }
+ else
+ {
+ if (!_fileSystem.DirectoryExists(request.Path))
+ {
+ throw new FileNotFoundException("File not found", request.Path);
+ }
+ }
+ }
+
+ else
+ {
+ if (!_fileSystem.FileExists(request.Path) && !_fileSystem.DirectoryExists(request.Path))
+ {
+ throw new FileNotFoundException("Path not found", request.Path);
+ }
+
+ if (request.ValidateWriteable)
+ {
+ EnsureWriteAccess(request.Path);
+ }
+ }
+ }
+
+ protected void EnsureWriteAccess(string path)
+ {
+ var file = Path.Combine(path, Guid.NewGuid().ToString());
+
+ _fileSystem.WriteAllText(file, string.Empty);
+ _fileSystem.DeleteFile(file);
+ }
+
public object Get(GetDefaultDirectoryBrowser request)
{
var result = new DefaultDirectoryBrowserInfo();