danny0405 commented on code in PR #13740:
URL: https://github.com/apache/hudi/pull/13740#discussion_r2289696341
##########
hudi-common/src/main/java/org/apache/hudi/common/util/ConfigUtils.java:
##########
@@ -685,11 +686,37 @@ public static TypedProperties fetchConfigs(
public static void recoverIfNeeded(HoodieStorage storage, StoragePath
cfgPath,
StoragePath backupCfgPath) throws
IOException {
+ boolean needCopy = false;
if (!storage.exists(cfgPath)) {
- // copy over from backup
- try (InputStream in = storage.open(backupCfgPath);
- OutputStream out = storage.create(cfgPath, false)) {
- FileIOUtils.copy(in, out);
+ needCopy = true;
+ } else {
+ TypedProperties props = new TypedProperties();
+ try (InputStream in = storage.open(cfgPath)) {
+ props.load(in);
+ if (!props.containsKey(TABLE_CHECKSUM.key()) ||
!HoodieTableConfig.validateChecksum(props)) {
+ // the cfg file is invalid
+ storage.deleteFile(cfgPath);
+ needCopy = true;
+ }
+ }
+ }
+ if (needCopy && storage.exists(backupCfgPath)) {
Review Comment:
when needCopy is true, the `backupCfgPath` must always exist?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]