Skip to content
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

Failing to keep a dynamic.css file in sync #47

Open
Grendel61 opened this issue Sep 7, 2015 · 8 comments
Open

Failing to keep a dynamic.css file in sync #47

Grendel61 opened this issue Sep 7, 2015 · 8 comments

Comments

@Grendel61
Copy link

The theme I'm using creates a dynamic CSS directory within uploads, and then generates a CSS based on various updates of settings and other hooks. When the CSS is generated the directory must be deleted and then recreated. S3-Uploads deletes the file and directory from S3, but then doesn't recreate it. However, S3-uploads must not be detecting the file being re-created. The result is that the browser looks for a directory and a CSS file that it can't find, and returns a 403.

It seems like the detection of the deletion occurs, because the directory and the file are deleted from S3. However, the re-creation of the file goes undetected, so the new directory and file aren't uploaded to S3.

Thoughts?

@Grendel61
Copy link
Author

When I force a copy I see this error.

Warning: copy(s3://foxtrotcode-media.s3.amazonaws.com/uploads/custom_styles/dynamic.css): failed to open stream: "S3_Uploads_Stream_Wrapper::stream_open" call failed in /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/S3-Uploads-master/inc/class-s3-uploads-wp-cli-command.php on line 405
Success: Completed copy from wp-content/uploads/custom_styles to s3://foxtrotcode-media.s3.amazonaws.com/uploads/custom_styles

The "Success:" was also was incorrect, it failed.

@joehoyle
Copy link
Member

joehoyle commented Sep 7, 2015

@Grendel61 it looks like your S3_UPLOADS_BUCKET but be incorrect, it should be foxtrotcode-media, it looks like you may have set it to foxtrotcode-media.s3.amazonaws.com?

@Grendel61
Copy link
Author

That worked as a fix on the copy, sorry about that.

What's your thought on the dynamic CSS problem?

@Grendel61
Copy link
Author

It is actually somewhat stranger, now that I investigated it more deeply.

I don't think the file dynamic.css is even getting recreated. It has a time stamp from many days ago when I first installed the upgrade to this theme.

It actually seems to just vanish from the S3, whenever anything is saved on the backend admin interface.

I have to use the cp command to move it back into S3.

Thoughts?

@joehoyle
Copy link
Member

joehoyle commented Sep 9, 2015

@Grendel61 what you explained should be working ok - is this is particular plugin or piece of code you could share?

Thanks

@Grendel61
Copy link
Author

It's not code I wrote, but for some reason every time I save any settings on the admin interface, the directory that holds this CSS is deleted by Upload-S3, and I have to CP the directory and file again to restore the CSS. Is there anyway to override Upload-S3 redirecting the path for this single file? Or is there a way to ensure that this directory isn't accidentally deleted? I'm not sure what is happening, but I think it has to be Upload-S3 deleting this directory. This directory is in the Uploads directory, and I'm trying to sync all the contents of the Upload directory to S3. In this case there seems to be a problem.

@Grendel61
Copy link
Author

So Joe,

Just trying to isolate this problem so we can fix it.

  • I assume Upload-S3 handles a file modification, because I'm assuming it is deleting the directory on S3? Will it delete a directory on S3?
  • Should it be deleting a directory, when the single file in the directory is modified? Is it the single file that's causing the problem like a loop error?
  • Why wouldn't Upload-S3 try to "sync" the new contents if it looked at the file modification as a delete and recreate?

Do you have any thoughts on this?

@Grendel61
Copy link
Author

I think I may have found the problem. It's probably beyond Upload-S3 to fix this. I've got multiple versions of the Wordpress App on different servers writing to the same S3 buckets. Normally they would be unlikely to have a conflict, because the S3 buckets mainly have image files that rarely get updated simultaneously. However, in this one case if I had two instances changing the admin panel, they would both try to write out to this one dynamic.css potentially. That would probably confuse Upload-S3 regarding the timestamps. Possibly one instance could lock the file which could be the "exclusive locks" error, and then the other instance couldn't write out to it.

This leads me to a question. The css file in question is in a directory called custom_styles by itself and it is called dynamic.css. Can you configure the Upload-S3 "--sync" command to ignore a directory? Is there a place where I could hack that. This file and directory should probably stay local.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants