Closed jwulf closed 6 years ago
Was able to replicate locally. It is due to some faulty handling in the endpoint filewriter
cache around deleting and updating files.
This bug would have sometimes manifested as an intermittent file syncing bug!
Anyways, I have deleted the filewriter
, and replaced it with a simple method on the main User
class:
https://github.com/jwulf/play.magikcraft.io-endpoint/commit/4c53112f32b86fb4b5ceedd3efb0f446d26a9fe9
writeFilesToFileSystem() {
// Add or update files.
this.files.forEach(file => {
const prevFile = this.prevFiles.find(f => `${f.name}.${f.ext}` === `${file.name}.${file.ext}`);
const isNew = (!prevFile);
const hasChanged = (prevFile && file.changed !== prevFile.changed);
if (isNew) {
// write new file
fs.writeFileSync(`${SPELLPATH}/${this.minecraftUsername}/${file.name}.js`, this.transpileFileContent(file));
debug(`Added file: ${this.minecraftUsername}/${file.name}.js`);
} else if (hasChanged) {
// delete old version of file.
fs.removeSync(`${SPELLPATH}/${this.minecraftUsername}/${file.name}.js`);
// write new version of file
fs.writeFileSync(`${SPELLPATH}/${this.minecraftUsername}/${file.name}.js`, this.transpileFileContent(file));
debug(`Updated file: ${this.minecraftUsername}/${file.name}.js`);
}
});
// delete files that no longer exist.
this.prevFiles.forEach(file => {
const stillExists = this.files.find(f => `${f.name}.${f.ext}` === `${file.name}.${file.ext}`);
if (!stillExists) {
fs.removeSync(`${SPELLPATH}/${this.minecraftUsername}/${file.name}.js`);
debug(`Deleted file: ${this.minecraftUsername}/${file.name}.js`);
}
});
}
Deploying now!
This is now fixed on the develop server.
I have observed some additional strange behavior... ATTN: @jwulf After deleting a spell, I can still cast it! After deleting I check the endpoint file system and the spell is gone, as expected. The logs even say so:
However, I can still cast the spell!
It seems that the spell engine, inside the plugin, has some kind of cache...
Anyways, should not cause too much trouble to users, as if I recreate the spell, the "cached" version gets overwritten.
Observed while Xx_MEDIARITE_xX was doing a video. Reproduced on my machine.
To reproduce:
fly
spell in your spellbook.fly
toultrafly
and saveSave
in spellbook/cast fly
”/cast fly
You do not have the spell fly
f
Save
in spellbook/cast f
”/cast f
Volare!
Part 2
/cast ultrafly
Volare!