mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-06 00:03:38 +00:00
Improved error handling
Minor improvement to error handling and small formatting changes
This commit is contained in:
@@ -8,14 +8,14 @@
|
|||||||
package duplicacy
|
package duplicacy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"strings"
|
|
||||||
"io/ioutil"
|
|
||||||
"os/exec"
|
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"time"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var snapshotPath string
|
var snapshotPath string
|
||||||
@@ -40,11 +40,14 @@ func CharsToString(ca []int8) string {
|
|||||||
|
|
||||||
// Get ID of device containing path
|
// Get ID of device containing path
|
||||||
func GetPathDeviceId(path string) (deviceId int32, err error) {
|
func GetPathDeviceId(path string) (deviceId int32, err error) {
|
||||||
|
|
||||||
stat := syscall.Stat_t{}
|
stat := syscall.Stat_t{}
|
||||||
|
|
||||||
err = syscall.Stat(path, &stat)
|
err = syscall.Stat(path, &stat)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return stat.Dev, nil
|
return stat.Dev, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,8 +86,12 @@ func DeleteShadowCopy() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
os.RemoveAll(snapshotPath)
|
err = os.RemoveAll(snapshotPath)
|
||||||
|
if err != nil {
|
||||||
|
LOG_ERROR("VSS_DELETE", "Error while deleting temporary mount directory")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
LOG_INFO("VSS_DELETE", "Shadow copy unmounted and deleted at %s", snapshotPath)
|
LOG_INFO("VSS_DELETE", "Shadow copy unmounted and deleted at %s", snapshotPath)
|
||||||
|
|
||||||
snapshotPath = ""
|
snapshotPath = ""
|
||||||
@@ -141,7 +148,7 @@ func CreateShadowCopy(top string, shadowCopy bool, timeoutInSeconds int) (shadow
|
|||||||
LOG_ERROR("VSS_CREATE", "Error while calling tmutil: ", err)
|
LOG_ERROR("VSS_CREATE", "Error while calling tmutil: ", err)
|
||||||
return top
|
return top
|
||||||
}
|
}
|
||||||
|
|
||||||
colonPos := strings.IndexByte(tmutilOutput, ':')
|
colonPos := strings.IndexByte(tmutilOutput, ':')
|
||||||
if colonPos < 0 {
|
if colonPos < 0 {
|
||||||
LOG_ERROR("VSS_CREATE", "Snapshot creation failed: ", tmutilOutput)
|
LOG_ERROR("VSS_CREATE", "Snapshot creation failed: ", tmutilOutput)
|
||||||
|
|||||||
Reference in New Issue
Block a user