Skip to content

Commit 55478e7

Browse files
fix: improve error handling and compatibility
Add directory existence check in CsvToDsConverter::dsToCsv. Allow null GAME align callback in TranscriptionPipeline. Fix FileIOProvider ownership to support test injection. Fix signed/unsigned comparison warning in Slicer. Adapt TestCsvToDsConverter to static DsDocument::loadFile API. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
1 parent e4bf73e commit 55478e7

5 files changed

Lines changed: 17 additions & 10 deletions

File tree

src/domain/src/CsvToDsConverter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ bool CsvToDsConverter::dsToCsv(const QString &dsDir,
247247
const QString &csvPath,
248248
QString &error) {
249249
QDir dir(dsDir);
250+
if (!dir.exists()) {
251+
error = QStringLiteral("Directory does not exist: ") + dsDir;
252+
return false;
253+
}
250254
const QFileInfoList entries = dir.entryInfoList(
251255
{QStringLiteral("*.ds")}, QDir::Files, QDir::Name);
252256

src/domain/src/TranscriptionPipeline.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ bool TranscriptionPipeline::gameAlign(const Options &opts,
241241
ProgressCallback progress,
242242
QString &error) {
243243
if (!gameAlignCb) {
244-
error = "GAME align callback is null";
245-
return false;
244+
// No callback — skip alignment, leave rows unchanged
245+
return true;
246246
}
247247

248248
const int total = static_cast<int>(rows.size());

src/framework/core/src/LocalFileIOProvider.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,21 @@ Result<void> LocalFileIOProvider::copyFile(const QString &src, const QString &ds
9898
return Result<void>::Ok();
9999
}
100100

101-
static std::unique_ptr<IFileIOProvider> s_provider =
101+
static std::unique_ptr<IFileIOProvider> s_ownedProvider =
102102
std::make_unique<LocalFileIOProvider>();
103+
static IFileIOProvider *s_activeProvider = s_ownedProvider.get();
103104

104105
IFileIOProvider *fileIOProvider() {
105-
return s_provider.get();
106+
return s_activeProvider;
106107
}
107108

108109
void setFileIOProvider(IFileIOProvider *provider) {
109-
s_provider.reset(provider);
110+
s_activeProvider = provider;
110111
}
111112

112113
void resetFileIOProvider() {
113-
s_provider = std::make_unique<LocalFileIOProvider>();
114+
s_ownedProvider = std::make_unique<LocalFileIOProvider>();
115+
s_activeProvider = s_ownedProvider.get();
114116
}
115117

116118
}

src/infer/audio-util/src/Slicer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace AudioUtil
3030
output.reserve(output_size);
3131

3232
for (size_t i = 0; i < output_size; ++i) {
33-
const bool is_underflow = i * hop_length < frame_length / 2;
33+
const bool is_underflow = static_cast<int>(i * hop_length) < frame_length / 2;
3434
const size_t start = is_underflow ? 0 : (i * hop_length - frame_length / 2);
3535
const size_t end = (std::min)(samples.size(), i * hop_length - frame_length / 2 + frame_length);
3636

@@ -72,7 +72,7 @@ namespace AudioUtil
7272
output.reserve(output_size);
7373

7474
for (size_t i = 0; i < output_size; ++i) {
75-
const bool is_underflow = i * hop_length < frame_length / 2;
75+
const bool is_underflow = static_cast<int>(i * hop_length) < frame_length / 2;
7676
const size_t start = is_underflow ? 0 : (i * hop_length - frame_length / 2);
7777
const size_t end = (std::min)(samples.size(), i * hop_length - frame_length / 2 + frame_length);
7878

src/tests/domain/TestCsvToDsConverter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,10 @@ void TestCsvToDsConverter::testConvertFromMemory_dsContentVerification() {
222222
QString error;
223223
QVERIFY(CsvToDsConverter::convertFromMemory(rows, opts, mockF0, nullptr, error));
224224

225-
DsDocument doc;
226225
QString dsPath = tmpOut.path() + "/song1.ds";
227-
QVERIFY(doc.loadFile(dsPath).ok());
226+
auto loadResult = DsDocument::loadFile(dsPath);
227+
QVERIFY(loadResult.ok());
228+
DsDocument doc = std::move(loadResult.value());
228229
QVERIFY(!doc.sentences().empty());
229230

230231
auto &s = doc.sentences()[0];

0 commit comments

Comments
 (0)