Fix permissions restore for version 6 (#2908)
Paths were not properly augmented for newer versions which removed the name from the `.dirmeta` file. This fixes that. It also adds a tests to ensure that the code will fail whenever we add a new version forcing us to revisit and update. --- #### Does this PR need a docs update or release note? - [x] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [ ] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [x] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * https://github.com/alcionai/corso/pull/2906 * fixes https://github.com/alcionai/corso/issues/2909 #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
e77a5e5a7e
commit
e09a98f462
@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased] (beta)
|
## [Unreleased] (beta)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fixed permissions restore in latest backup version
|
||||||
|
|
||||||
## [v0.6.1] (beta) - 2023-03-21
|
## [v0.6.1] (beta) - 2023-03-21
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@ -646,7 +646,15 @@ func AugmentRestorePaths(backupVersion int, paths []path.Path) ([]path.Path, err
|
|||||||
// collection.
|
// collection.
|
||||||
for _, p := range colPaths {
|
for _, p := range colPaths {
|
||||||
el := p.Elements()
|
el := p.Elements()
|
||||||
if backupVersion >= version.OneDrive4DirIncludesPermissions {
|
|
||||||
|
if backupVersion >= version.OneDrive6NameInMeta {
|
||||||
|
mPath, err := p.Append(".dirmeta", true)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
paths = append(paths, mPath)
|
||||||
|
} else if backupVersion >= version.OneDrive4DirIncludesPermissions {
|
||||||
mPath, err := p.Append(el[len(el)-1]+".dirmeta", true)
|
mPath, err := p.Append(el[len(el)-1]+".dirmeta", true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@ -21,6 +21,12 @@ func TestRestoreUnitSuite(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RestoreUnitSuite) TestAugmentRestorePaths() {
|
func (suite *RestoreUnitSuite) TestAugmentRestorePaths() {
|
||||||
|
// Adding a simple test here so that we can be sure that this
|
||||||
|
// function gets updated whenever we add a new version.
|
||||||
|
if version.Backup > version.OneDrive6NameInMeta {
|
||||||
|
require.Less(suite.T(), version.OneDrive6NameInMeta+1, version.Backup, "unsupported backup version")
|
||||||
|
}
|
||||||
|
|
||||||
table := []struct {
|
table := []struct {
|
||||||
name string
|
name string
|
||||||
version int
|
version int
|
||||||
@ -121,6 +127,41 @@ func (suite *RestoreUnitSuite) TestAugmentRestorePaths() {
|
|||||||
"folder/folder2/folder2.dirmeta",
|
"folder/folder2/folder2.dirmeta",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "no change v6",
|
||||||
|
version: version.OneDrive6NameInMeta,
|
||||||
|
input: []string{
|
||||||
|
"file.txt.data",
|
||||||
|
},
|
||||||
|
output: []string{
|
||||||
|
"file.txt.data",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "one folder v6",
|
||||||
|
version: version.OneDrive6NameInMeta,
|
||||||
|
input: []string{
|
||||||
|
"folder/file.txt.data",
|
||||||
|
},
|
||||||
|
output: []string{
|
||||||
|
"folder/.dirmeta",
|
||||||
|
"folder/file.txt.data",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "nested folders v6",
|
||||||
|
version: version.OneDrive6NameInMeta,
|
||||||
|
input: []string{
|
||||||
|
"folder/file.txt.data",
|
||||||
|
"folder/folder2/file.txt.data",
|
||||||
|
},
|
||||||
|
output: []string{
|
||||||
|
"folder/.dirmeta",
|
||||||
|
"folder/file.txt.data",
|
||||||
|
"folder/folder2/.dirmeta",
|
||||||
|
"folder/folder2/file.txt.data",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user