-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: During upgrade i get some errors #119
Comments
new images attach and display |
Same behavior, here's what allowed me to finish the migration: diff --git a/migrations/20240929-autumn-rewrite.mjs b/migrations/20240929-autumn-rewrite.mjs
index c8643bc..1ab854a 100644
--- a/migrations/20240929-autumn-rewrite.mjs
+++ b/migrations/20240929-autumn-rewrite.mjs
@@ -26,12 +26,38 @@ const BUCKET_MAP = {
*
* TODO: change if necessary
*/
-const CONNECTION_URL = "mongodb://database";
+const CONNECTION_URL = "mongodb://database:27017";
const mongo = new MongoClient(CONNECTION_URL);
await mongo.connect();
+const objectLookup = {};
+
+/**
+ * Decode timestamp from Ulid
+ * @param {string} id Ulid string
+ * @returns {number} Timestamp in milliseconds
+ */
+function decodeTime(id) {
+ // First 10 characters of ULID represent milliseconds precision timestamp
+ const timestamp = id.substring(0, 10);
+ // Convert from base32 to decimal
+ const base32Chars = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
+ let decoded = 0;
+ for (let i = 0; i < timestamp.length; i++) {
+ const char = timestamp[i];
+ const value = base32Chars.indexOf(char.toUpperCase());
+ if (value === -1) {
+ throw new Error(`Invalid ULID character: ${char}`);
+ }
+ decoded = decoded * 32 + value;
+ }
+ // ULID timestamps are in milliseconds
+ return decoded;
+}
+
async function determineUploaderIdAndUse(f, v, i) {
+ console.log(`Processing file ${i}:`, f._id);
if (f.tag === "attachments" && v === "attachments") {
if (typeof f.message_id !== "string") {
console.warn(i, "No message id specified.");
@@ -39,6 +65,7 @@ async function determineUploaderIdAndUse(f, v, i) {
}
if (!objectLookup[f.message_id]) {
+ console.log(`Querying database for message ${f.message_id}`);
objectLookup[f.message_id] = await mongo
.db("revolt")
.collection("messages")
@@ -52,6 +79,7 @@ async function determineUploaderIdAndUse(f, v, i) {
return null;
}
+ console.log(`Found message ${f.message_id} for file ${f._id}`);
return {
uploaded_at: new Date(decodeTime(f.message_id)),
uploader_id: objectLookup[f.message_id].author,
@@ -368,6 +396,7 @@ const files_pt2 = await mongo
})
.toArray();
+if (files_pt2.length > 0) {
await mongo
.db("revolt")
.collection("attachment_hashes")
@@ -403,3 +432,10 @@ for (const file of files_pt2) {
}
);
}
+} else {
+ console.log("No files to process in files_pt2.");
+}
+
+await mongo.close();
+console.log("Migration completed successfully.");
+process.exit(0); And while the autumn server base URL responds with |
Well, we're in this together. I'll see what I can do soon enough but i'm pretty sure it's out of my reach. |
I think we need to compare this piece of code with the old autumn, see how the attachments worked in the old one |
In my opinion, the migration is not doing its job properly because of my manual dirty fix, hence the missing of attachment retrieval and this error |
What happened?
hello, please help me finish updrad#84
run the migration: get error
And if I continue and run containers, I don't see attachments, it says that the files don't exist![test](https://camo.githubusercontent.com/fd14cc4de98708f308e9c6a480a8458a82663912d3150e2acd2035b0c4fc4ace/68747470733a2f2f692e6962622e636f2f587931564e51502f746573742e706e67)
The text was updated successfully, but these errors were encountered: