Esempio n. 1
0
        /// <summary>
        ///     Creates a new repository folder from scratch
        /// </summary>
        /// <returns></returns>
        public void CreateDirectories(bool performFullCheckout)
        {
            if (!Directory.Exists(PhysicalDirectory.FullName))
            {
                Directory.CreateDirectory(PhysicalDirectory.FullName);
            }
            if (!Directory.Exists(Mountpoint.FullName))
            {
                Directory.CreateDirectory(Mountpoint.FullName);
            }

            if (CreateNew)
            {
                var result = GetCommandLineOutput("cmd.exe", "/C gin.exe create " + Name,
                                                  PhysicalDirectory.Parent.FullName, out var error);

                if (!string.IsNullOrEmpty(error))
                {
                    OnFileOperationError(error);
                }
            }
            else
            {
                if (PhysicalDirectory.IsEmpty())
                {
                    OnFileOperationStarted(new FileOperationEventArgs {
                        File = Address
                    });

                    GetCommandLineOutputEvent("cmd.exe", "/C gin.exe get --json " + Address,
                                              PhysicalDirectory.Parent.FullName, out var error);

                    var result = string.IsNullOrEmpty(error);

                    if (result)
                    {
                        OnFileOperationCompleted(new FileOperationEventArgs {
                            File = Address, Success = true
                        });
                    }
                    else
                    {
                        OnFileOperationError(error);
                    }
                }

                if (performFullCheckout)
                {
                    OnFileOperationStarted(new FileOperationEventArgs {
                        File = Address
                    });

                    GetCommandLineOutputEvent("cmd.exe", "/C gin.exe download --json --content",
                                              PhysicalDirectory.Parent.FullName, out var error);

                    var result = string.IsNullOrEmpty(error);

                    if (result)
                    {
                        OnFileOperationCompleted(new FileOperationEventArgs {
                            File = Address, Success = true
                        });
                    }
                    else
                    {
                        OnFileOperationError(error);
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Creates a new repository folder from scratch
        /// </summary>
        /// <returns></returns>
        public bool CreateDirectories(bool performFullCheckout)
        {
            try
            {
                if (!Directory.Exists(PhysicalDirectory.FullName))
                {
                    Directory.CreateDirectory(PhysicalDirectory.FullName);
                }
            }
            catch (Exception e)
            {
                OnFileOperationError("Could not create checkout directory. Exception: " + e.Message + "\n InnerException: " + e.InnerException);
                return(false);
            }

            try
            {
                if (!Directory.Exists(Mountpoint.FullName))
                {
                    Directory.CreateDirectory(Mountpoint.FullName);
                }
            }
            catch (Exception e)
            {
                OnFileOperationError("Could not create mountpoint directory. Exception: " + e.Message + "\n InnerException: " + e.InnerException);
                return(false);
            }

            if (PhysicalDirectory.IsEmpty())
            {
                OnFileOperationStarted(new FileOperationEventArgs {
                    File = Address
                });
                GetCommandLineOutputEvent(GinCliExe, " get --json " + Address,
                                          PhysicalDirectory.Parent.FullName, out var error);
                var result = string.IsNullOrEmpty(error);
                if (result)
                {
                    OnFileOperationCompleted(new FileOperationEventArgs {
                        File = Address, Success = true
                    });
                }
                else
                {
                    OnFileOperationError(error);
                    return(false);
                }
            }

            if (performFullCheckout)
            {
                OnFileOperationStarted(new FileOperationEventArgs {
                    File = Address
                });
                GetCommandLineOutputEvent(GinCliExe, " download --json --content",
                                          PhysicalDirectory.FullName, out var error);
                var result = string.IsNullOrEmpty(error);
                if (result)
                {
                    OnFileOperationCompleted(new FileOperationEventArgs {
                        File = Address, Success = true
                    });
                }
                else
                {
                    OnFileOperationError(error);
                    return(false);
                }
            }
            return(true);
        }