vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   finding attachment (https://vborg.vbsupport.ru/showthread.php?t=320733)

chikuru 11-08-2015 12:50 AM

finding attachment
 
How can i find the attachment in filesystem?

Example attachment :
attachment.php?attachmentid=57356

Dragonsys 11-08-2015 02:52 AM

look in the ACP under attachments. Are you even storing them in the File System? The files are given a numeric name, so you cannot just browse the file system and find them.

If you are storing in the FS (and not in the DB) you can search the DB (attachments table) to find the path. Or in the ACP you can Search Attachments, and get the ID that way

chikuru 11-10-2015 05:30 AM

The attachments are stored in the File System.

When I go to the forum, the attachment link is: attachment.php?attachmentid=57356

How can I find the attachment in the attachment directory?

Lynne 11-10-2015 04:43 PM

They are stored by userid. So, go to the attachment directory and if the userid is 1234, then look in the directory /1, then in /2, then in /3, and then in /4 and it should be in there.

chikuru 11-11-2015 08:45 AM

Most attachment from certain user arent showing anymore. I tried searching the filenames via SSH but they are on different directories. Scattered everywhere in different USERIDs.

Manually moving of the attachment files (.thumb and .attach) doesnt make the attachments show.
How can I make the attachments work again? Simply moving the files didnt work..

Lynne 11-11-2015 09:27 PM

You cannot just go moving attachments from one directory to another.

What is the exact problem you were having when you started this thread? You never said exactly. I simply told you were the attachments were stored. To get the actual .attach and .thumb number, you need to look at the attachment table, look up the attachmentid and get the filedataid. They will be listed as filedataid.attach and filedataid.thumb in the file system.

squidsk 11-12-2015 02:42 PM

Have you recently upgraded to 4.2.3?

chikuru 11-12-2015 03:10 PM

Quote:

Originally Posted by Lynne (Post 2558610)
You cannot just go moving attachments from one directory to another.

What is the exact problem you were having when you started this thread? You never said exactly. I simply told you were the attachments were stored. To get the actual .attach and .thumb number, you need to look at the attachment table, look up the attachmentid and get the filedataid. They will be listed as filedataid.attach and filedataid.thumb in the file system.

Its in post #5
Most attachment from certain users arent showing anymore. I tried searching the filenames via SSH but they are on different directories. Scattered everywhere in different USERIDs.

Quote:

Originally Posted by squidsk (Post 2558633)
Have you recently upgraded to 4.2.3?

Yes you are correct..

squidsk 11-12-2015 03:34 PM

There's a bug in 4.2.3 where attachments get deleted on upgrading to 4.2.3. In previous versions of vbulletin there was a bug in the daily cron cleanup script that prevented unused attachments from being deleted. That bug was fixed in 4.2.3. The problem was the refcount field in the filedata table could have incorrect values in it, specifically 0 (i.e. unused filedata) when it shouldn't, making vbulletin think an attachment isn't being used when it in fact is being used.

So when the bug preventing unused filedata from being removed was fixed it removed all unused filedata which included the filedata with bad refcounts. Short of having a backup of the attachments directory from before the upgrade there's no way to recover the lost attachments.

chikuru 11-13-2015 02:46 AM

Quote:

Originally Posted by squidsk (Post 2558635)
There's a bug in 4.2.3 where attachments get deleted on upgrading to 4.2.3. In previous versions of vbulletin there was a bug in the daily cron cleanup script that prevented unused attachments from being deleted. That bug was fixed in 4.2.3. The problem was the refcount field in the filedata table could have incorrect values in it, specifically 0 (i.e. unused filedata) when it shouldn't, making vbulletin think an attachment isn't being used when it in fact is being used.

So when the bug preventing unused filedata from being removed was fixed it removed all unused filedata which included the filedata with bad refcounts. Short of having a backup of the attachments directory from before the upgrade there's no way to recover the lost attachments.

We have backup of the forum directory including the attachments folder prior to upgrade. Is it possible to recover the attachments using that copy?

squidsk 11-13-2015 05:32 AM

if you also had a db backup then yes. Restore everything to how it was before the upgrade then run a query to correct the ref counts, then upgrade again.

chikuru 11-13-2015 06:39 AM

Quote:

Originally Posted by squidsk (Post 2558685)
if you also had a db backup then yes. Restore everything to how it was before the upgrade then run a query to correct the ref counts, then upgrade again.

You know the query to run the refs counts? or where can I find it?

squidsk 11-13-2015 02:15 PM

Quote:

Originally Posted by chikuru (Post 2558690)
You know the query to run the refs counts? or where can I find it?

[sql]UPDATE filedata
LEFT JOIN (
SELECT filedataid, COUNT(attachmentid) AS actual
FROM attachment
GROUP BY filedataid
) list USING (filedataid)
SET refcount = IFNULL(actual, 0)
WHERE refcount <> IFNULL(actual, 0)[/sql]

You'll need to add the table prefix to the table names if your setup uses them. Also as I noted for this query to work the filedata and attachment tables need to be in their pre-upgraded state. Your other option is to reset to 4.2.2 and wait for the 4.2.4 upgrade which includes the above query in the upgrade process.

The query was posted at http://www.vbulletin.com/forum/forum...17#post4330417

chikuru 11-13-2015 02:20 PM

We already upgraded to vb 4.2.3 a month ago..
We have pre upgrade backup. But too old to restore to live site.

What action would you suggest to perform? Should I restore the backup then run this query and merge the database table/s to the live site? If yes, which table/s?

Thank You!

---
Edit:
I guess we will proceed with Paul's suggestion here:
http://www.vbulletin.com/forum/forum...22#post4330622

squidsk 11-13-2015 03:05 PM

You could just restore the attachment and filedata tables to a temporary db, run the query to fix the filedata. Run insert ignore queries on the live database using the content of the temp db tables as the source to restore the lost filedata and attachment data. Once that's done merge a restored copy of the attachment folder with the live copy of the attachment folder.

Take a backup before attempting any of this.

r5mjh 03-15-2016 10:14 PM

ok looks like this is my problem too as im upgrading to 423 too

so correct me if im wrong i need to run the query in my 371 duplicate first then upgrade to 423?

and is it the query above, dave supplied me another query setting it to 1

help appreciated guys as aways


All times are GMT. The time now is 05:05 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01973 seconds
  • Memory Usage 1,752KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (16)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete