@@ -9,7 +9,7 @@ import { CreateBucketRequest, Storage } from "@google-cloud/storage";
9
9
import { StorageTransferServiceClient } from "@google-cloud/storage-transfer" ;
10
10
import { uuid } from "@cocalc/util/misc" ;
11
11
import { getGoogleCloudPrefix } from "./index" ;
12
- import { addStorageTransferPolicy } from "./policy" ;
12
+ import { addStorageTransferPolicy , getProjectNumber } from "./policy" ;
13
13
import type { GoogleCloudBucketStorageClass } from "@cocalc/util/db-schema/cloud-filesystems" ;
14
14
import { GOOGLE_CLOUD_BUCKET_STORAGE_CLASSES } from "@cocalc/util/db-schema/cloud-filesystems" ;
15
15
@@ -73,11 +73,15 @@ export async function deleteFilesUsingTransferService(
73
73
// We fix this by doing just that via the api as given below.
74
74
// We only need to do this once, which is why the awkward style of this code,
75
75
// where it fails and tries this.
76
- const [ serviceAccount ] = await transferClient . getGoogleServiceAccount ( ) ;
77
- const { accountEmail } = serviceAccount ;
78
- if ( ! accountEmail ) {
79
- throw Error ( "unable to get storage transfer service email" ) ;
80
- }
76
+ // const [serviceAccount] = await transferClient.getGoogleServiceAccount();
77
+ // const { accountEmail } = serviceAccount;
78
+ // if (!accountEmail) {
79
+ // throw Error("unable to get storage transfer service email");
80
+ // }
81
+ // I can't get the above to work ! -- at least with all the permissions and api's I know about enabling.
82
+ // Fortunately the service account email for the transfer client follows a predictable pattern,
83
+ // so we just use that:
84
+ const accountEmail = `project-${ await getProjectNumber ( ) } @storage-transfer-service.iam.gserviceaccount.com` ;
81
85
await addStorageTransferPolicy ( accountEmail ) ;
82
86
}
83
87
0 commit comments