//NOTE: this now assumes that version control is on and we are not working offline. Also all paths are expected to be versioned public static void OnWillDeleteAssets(string[] assetPaths, AssetDeleteResult[] deletionResults, RemoveAssetOptions option) { Assert.IsTrue(deletionResults.Length == assetPaths.Length); //NOTE: we only submit assets for deletion in batches because PlasticSCM will time out the // connection to the provider process with too many assets int deletionBatchSize = 1000; for (int batchStart = 0; batchStart < assetPaths.Length; batchStart += deletionBatchSize) { var deleteAssetList = new AssetList(); for (int i = batchStart; i < batchStart + deletionBatchSize && i < assetPaths.Length; i++) { Asset asset = Provider.GetAssetByPath(assetPaths[i]); deleteAssetList.Add(asset); if (asset == null) { Debug.LogWarningFormat("Asset not found in path '{0}', (null) value returned", assetPaths[i]); } } Task task = null; try { task = Provider.Delete(deleteAssetList); task.SetCompletionAction(CompletionAction.UpdatePendingWindow); task.Wait(); } catch (Exception e) { Debug.LogWarningFormat("Not all files were deleted by version control: {0}", e.Message); } if (task != null && task.success) { for (int i = batchStart; i < batchStart + deleteAssetList.Count(); i++) { deletionResults[i] = File.Exists(assetPaths[i]) ? AssetDeleteResult.DidNotDelete : AssetDeleteResult.DidDelete; } } else { //NOTE: we most likely don't know which assets failed to actually be deleted for (int i = batchStart; i < batchStart + deleteAssetList.Count(); i++) { deletionResults[i] = AssetDeleteResult.FailedDelete; } } } }
//NOTE: this now assumes that version control is on and we are not working offline. Also all paths are expected to be versioned public static void OnWillDeleteAssets(string[] assetPaths, AssetDeleteResult[] deletionResults, RemoveAssetOptions option) { Assert.IsTrue(deletionResults.Length == assetPaths.Length); //NOTE: we only submit assets for deletion in batches because PlasticSCM will time out the // connection to the provider process with too many assets int deletionBatchSize = 1000; for (int batchStart = 0; batchStart < assetPaths.Length; batchStart += deletionBatchSize) { var deleteAssetList = new AssetList(); for (int i = batchStart; i < batchStart + deletionBatchSize && i < assetPaths.Length; i++) { deleteAssetList.Add(Provider.GetAssetByPath(assetPaths[i])); } Task task = Provider.Delete(deleteAssetList); task.SetCompletionAction(CompletionAction.UpdatePendingWindow); task.Wait(); if (task.success) { for (int i = batchStart; i < batchStart + deleteAssetList.Count(); i++) { deletionResults[i] = File.Exists(assetPaths[i]) ? AssetDeleteResult.DidNotDelete : AssetDeleteResult.DidDelete; } } else { //NOTE: we most likely don't know which assets failed to actually be deleted for (int i = batchStart; i < batchStart + deleteAssetList.Count(); i++) { deletionResults[i] = AssetDeleteResult.FailedDelete; } ; } } }