Ejemplo n.º 1
0
        /// <inheritdoc />
        protected override async Task InitControllers(Task chatTask, ReattachInformation reattachInfo, CancellationToken cancellationToken)
        {
            try
            {
                await base.InitControllers(chatTask, reattachInfo, cancellationToken).ConfigureAwait(false);
            }
            finally
            {
                // Then we move it back and apply the symlink
                if (directoryHardLinked)
                {
                    Logger.LogTrace("Unhardlinking compile job...");
                    Server?.Suspend();
                    await GameIOManager.MoveDirectory(
                        ActiveSwappable.Directory,
                        ActiveSwappable.CompileJob.DirectoryName.ToString(),
                        default)
                    .ConfigureAwait(false);

                    directoryHardLinked = false;
                }
            }

            if (reattachInfo != null)
            {
                Logger.LogTrace("Skipping symlink due to reattach");
                return;
            }

            Logger.LogTrace("Symlinking compile job...");
            await ActiveSwappable.MakeActive(cancellationToken).ConfigureAwait(false);

            Server.Resume();
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        protected override async Task InitControllers(Task chatTask, ReattachInformation reattachInfo, CancellationToken cancellationToken)
        {
            try
            {
                await base.InitControllers(chatTask, reattachInfo, cancellationToken).ConfigureAwait(false);
            }
            finally
            {
                // Then we move it back and apply the symlink
                if (hardLinkedDmb != null)
                {
                    try
                    {
                        Logger.LogTrace("Unhardlinking compile job...");
                        Server?.Suspend();
                        var hardLink         = hardLinkedDmb.Directory;
                        var originalPosition = hardLinkedDmb.CompileJob.DirectoryName.ToString();
                        await GameIOManager.MoveDirectory(
                            hardLink,
                            originalPosition,
                            default)
                        .ConfigureAwait(false);
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError(
                            ex,
                            "Failed to un-hard link compile job #{0} ({1})",
                            hardLinkedDmb.CompileJob.Id,
                            hardLinkedDmb.CompileJob.DirectoryName);
                    }

                    hardLinkedDmb = null;
                }
            }

            if (reattachInfo != null)
            {
                Logger.LogTrace("Skipping symlink due to reattach");
                return;
            }

            Logger.LogTrace("Symlinking compile job...");
            await ActiveSwappable.MakeActive(cancellationToken).ConfigureAwait(false);

            Server.Resume();
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        protected override async Task InitialLink(CancellationToken cancellationToken)
        {
            // The logic to check for an active live directory is in SwappableDmbProvider, so we just do it again here for safety
            Logger.LogTrace("Hard linking compile job...");

            // Symlinks are counted as a file on linux??
            if (await GameIOManager.DirectoryExists(ActiveSwappable.Directory, cancellationToken).ConfigureAwait(false))
            {
                await GameIOManager.DeleteDirectory(ActiveSwappable.Directory, cancellationToken).ConfigureAwait(false);
            }
            else
            {
                await GameIOManager.DeleteFile(ActiveSwappable.Directory, cancellationToken).ConfigureAwait(false);
            }

            // Instead of symlinking to begin with we actually rename the directory
            await GameIOManager.MoveDirectory(
                ActiveSwappable.CompileJob.DirectoryName.ToString(),
                ActiveSwappable.Directory,
                cancellationToken)
            .ConfigureAwait(false);

            hardLinkedDmb = ActiveSwappable;
        }