Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: file created time in zip (#11561)
ecmadao2ed2a981d307
diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.goindex 0c8d68af68..a3c7f9e901 100644--- a/backend/api/v1/sql_service.go+++ b/backend/api/v1/sql_service.go@@ -492,9 +492,13 @@ func DoEncrypt(data []byte, request *v1pb.ExportRequest) ([]byte, error) {zipw := zip.NewWriter(fzip)defer zipw.Close()- filename := fmt.Sprintf("export.%s", strings.ToLower(request.Format.String()))-- writer, err := zipw.Encrypt(filename, request.Password)+ fh := &zip.FileHeader{+ Name: fmt.Sprintf("export.%s", strings.ToLower(request.Format.String())),+ Method: zip.Deflate,+ }+ fh.ModifiedDate, fh.ModifiedTime = timeToMsDosTime(time.Now())+ fh.SetPassword(request.Password)+ writer, err := zipw.CreateHeader(fh)if err != nil {return nil, errors.Wrapf(err, "failed to create encrypt export file")}@@ -509,6 +513,14 @@ func DoEncrypt(data []byte, request *v1pb.ExportRequest) ([]byte, error) {return b.Bytes(), nil}+// timeToMsDosTime converts a time.Time to an MS-DOS date and time.+// this is a modified copy for gihub.com/alexmullins/zip/struct.go cause the package has a bug, it will convert the time to UTC time and drop the timezone.+func timeToMsDosTime(t time.Time) (uint16, uint16) {+ fDate := uint16(t.Day() + int(t.Month())<<5 + (t.Year()-1980)<<9)+ fTime := uint16(t.Second()/2 + t.Minute()<<5 + t.Hour()<<11)+ return fDate, fTime+}+func (s *SQLService) createExportActivity(ctx context.Context, user *store.UserMessage, level api.ActivityLevel, instanceUID int, database *store.DatabaseMessage, payload api.ActivitySQLExportPayload) (*store.ActivityMessage, error) {// TODO: use v1 activity API instead ofactivityBytes, err := json.Marshal(payload)