mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
avoid unnecessary file rewrites
This commit is contained in:
parent
5e590aa16a
commit
b698ab9dd4
@ -80,7 +80,7 @@ project, please check the [project management guide](./PROJECT.md) to get starte
|
||||
- ✅ Perplexity Integration (@meetpateltech)
|
||||
- ✅ AWS Bedrock Integration (@kunjabijukchhe)
|
||||
- ✅ Add a "Diff View" to see the changes (@toddyclipsgg)
|
||||
- ⬜ **HIGH PRIORITY** - Prevent bolt from rewriting files as often (file locking and diffs)
|
||||
- ✅ **HIGH PRIORITY** - Prevent bolt from rewriting files as often (file locking and diffs)
|
||||
- ⬜ **HIGH PRIORITY** - Better prompting for smaller LLMs (code window sometimes doesn't start)
|
||||
- ⬜ **HIGH PRIORITY** - Run agents in the backend as opposed to a single model call
|
||||
- ✅ Deploy directly to Netlify (@xKevIsDev)
|
||||
|
@ -196,17 +196,23 @@ const getFs = (
|
||||
}
|
||||
|
||||
try {
|
||||
// Handle encoding properly based on data type
|
||||
if (data instanceof Uint8Array) {
|
||||
// For binary data, don't pass encoding
|
||||
const result = await webcontainer.fs.writeFile(relativePath, data);
|
||||
return result;
|
||||
} else {
|
||||
// For text data, use the encoding if provided
|
||||
const encoding = options?.encoding || 'utf8';
|
||||
const result = await webcontainer.fs.writeFile(relativePath, data, encoding);
|
||||
const existing = await webcontainer.fs.readFile(relativePath).catch(() => null);
|
||||
|
||||
return result;
|
||||
if (existing && Buffer.compare(existing, data) === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
return await webcontainer.fs.writeFile(relativePath, data);
|
||||
} else {
|
||||
const encoding = options?.encoding || 'utf8';
|
||||
const existing = await webcontainer.fs.readFile(relativePath, encoding).catch(() => null);
|
||||
|
||||
if (typeof existing === 'string' && existing === data) {
|
||||
return;
|
||||
}
|
||||
|
||||
return await webcontainer.fs.writeFile(relativePath, data, encoding);
|
||||
}
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
@ -322,6 +322,19 @@ export class ActionRunner {
|
||||
}
|
||||
|
||||
try {
|
||||
let existing: string | null = null;
|
||||
|
||||
try {
|
||||
existing = await webcontainer.fs.readFile(relativePath, 'utf-8');
|
||||
} catch {
|
||||
existing = null;
|
||||
}
|
||||
|
||||
if (existing !== null && existing === action.content) {
|
||||
logger.debug(`Skipped writing ${relativePath} (no changes)`);
|
||||
return;
|
||||
}
|
||||
|
||||
await webcontainer.fs.writeFile(relativePath, action.content);
|
||||
logger.debug(`File written ${relativePath}`);
|
||||
} catch (error) {
|
||||
|
@ -563,7 +563,17 @@ export class FilesStore {
|
||||
unreachable('Expected content to be defined');
|
||||
}
|
||||
|
||||
await webcontainer.fs.writeFile(relativePath, content);
|
||||
try {
|
||||
const existing = await webcontainer.fs.readFile(relativePath, 'utf-8');
|
||||
|
||||
if (existing === content) {
|
||||
logger.debug(`Skipped writing ${relativePath} (no changes)`);
|
||||
} else {
|
||||
await webcontainer.fs.writeFile(relativePath, content);
|
||||
}
|
||||
} catch {
|
||||
await webcontainer.fs.writeFile(relativePath, content);
|
||||
}
|
||||
|
||||
if (!this.#modifiedFiles.has(filePath)) {
|
||||
this.#modifiedFiles.set(filePath, oldContent);
|
||||
|
Loading…
Reference in New Issue
Block a user