fix folder deletion failures (#867)
## Description Graph clips time values ending in :00 from folder names. In order for the purge handler to check the time values correctly, we need to identify those folders and reinstate the 00 seconds tail. ## Type of change - [x] 🐛 Bugfix ## Issue(s) * #805 ## Test Plan - [x] 💪 Manual
This commit is contained in:
parent
a6ba26cd92
commit
1d24d575ca
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -246,6 +247,16 @@ func purgeContactFolders(ctx context.Context, gc *connector.GraphConnector, boun
|
|||||||
|
|
||||||
// ----- controller
|
// ----- controller
|
||||||
|
|
||||||
|
var secfmt = regexp.MustCompile(`.+:0-9{2}:0-9{2}`)
|
||||||
|
|
||||||
|
func normalizeDisplayName(dn string) string {
|
||||||
|
if !secfmt.MatchString(dn) {
|
||||||
|
dn += ":00"
|
||||||
|
}
|
||||||
|
|
||||||
|
return dn
|
||||||
|
}
|
||||||
|
|
||||||
func purgeFolders(
|
func purgeFolders(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
gc *connector.GraphConnector,
|
gc *connector.GraphConnector,
|
||||||
@ -268,13 +279,14 @@ func purgeFolders(
|
|||||||
var (
|
var (
|
||||||
del bool
|
del bool
|
||||||
displayName = *fld.GetDisplayName()
|
displayName = *fld.GetDisplayName()
|
||||||
dnLen = len(displayName)
|
normName = normalizeDisplayName(*fld.GetDisplayName())
|
||||||
|
dnLen = len(normName)
|
||||||
)
|
)
|
||||||
|
|
||||||
if dnLen > stLen {
|
if dnLen > stLen {
|
||||||
dnSuff := displayName[dnLen-stLen:]
|
suff := normName[dnLen-stLen:]
|
||||||
|
|
||||||
dnTime, err := common.ParseTime(dnSuff)
|
dnTime, err := common.ParseTime(suff)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Info(ctx, errors.Wrapf(err, "Error: deleting %s folder [%s]", data, displayName))
|
Info(ctx, errors.Wrapf(err, "Error: deleting %s folder [%s]", data, displayName))
|
||||||
continue
|
continue
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user