delCopies method
Delete old copies of file with name
in spaces
and keep number of latest copy.
name
is filenamespaces
Google Drive Space. default to 'appDataFolder'keepNumberOfLatest
copy to be kept
Implementation
Future delCopies({
required String name,
String spaces = lazy.defaultGDriveSpace,
int keepNumberOfLatest = 5,
}) async {
var debugPrefix = '$runtimeType.cleanUpOldFiles()';
List<gd.File> gFiles = await listFiles(
name: name,
spaces: spaces,
);
if (gFiles.length > keepNumberOfLatest) {
for (var gFile in gFiles.sublist(0, gFiles.length - keepNumberOfLatest)) {
if (gFile.id != null) {
lazy.log('$debugPrefix: deleted ${gFile.name} id: ${gFile.id}');
del(gFile.id!);
}
}
}
}