SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 34 of 34
  1. #26
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,914
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    Of the file contents.

    Uh huh...if you get a conflict then it is likely the SAME FILE.
    Rewind...

    So if you upload a photo of yourself, and I upload a photo of myself - obviously very different - they each of of photo files could never create a "collision" even though they clearly have different bit configurations?


    Secondly, if your answer above is, "No two image files that are different can have the same hash" then I would like to know if you have any easy ways to handle different people possibly uploading the same picture? (Maybe there are a lot of people who like Brad Pitt and so they use his image as profile image. How can I allow that to happen without getting all complicated?!)


    Debbie

  2. #27
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DoubleDee View Post
    So if you upload a photo of yourself, and I upload a photo of myself - obviously very different - they each of of photo files could never create a "collision" even though they clearly have different bit configurations?
    The two files in question would never return the same hash. Ever. Changing one bit in a file changes the hash.


    Secondly..How can I allow that to happen without getting all complicated?!)
    You don't have to do anything, just reference the same file in the database. They'll share the same file without causing issues.
    You'll only have to watch out if you delete, by making sure no one else references that file.

    It is akin to hardlinks in the file systems. One file with multiple aliases/names attached to it.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #28
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    Likely, but not guaranteed. =p

    I like watching out for those 1 in a billion chances (or 1 in 42,949,672,960,000,000,000,000,000 chances... my argument still stands. =p)

    Also, larger files take longer to hash, so it can be slower. SHA1 is O(n), so the larger n is, the longer it takes. My method is O(1), so it's pretty much constant.

  4. #29
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Been observing this thread and wondering why not something simple...
    Code:
    $path = PATH TO YOUR IMAGES sans image name
    $ext = EXTENTION OF IMAGE
    $does_it = 0;
    while($does_it = 0) {
    	$new_name = time() . $ext;
    	if (!file_exists($path . $new_name)) {
    		$does_it = 1;
    	}
    }

  5. #30
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by samanime View Post
    ...My method is O(1), so it's pretty much constant.
    Until you start accessing those directories. ext3/4 do have a real directory limit (~32000 for ext3). Unlike files, too many directories have a real negative impact on performance. You might want to look that up.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  6. #31
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by DoubleDee View Post
    Yes, that helps and seems in line with my own thinking.

    I appreciate the other competing views, but I have a long ways to go before the # of Files in a Directory or anything else becomes an issue?!

    Thanks for the nice words and well-wishes. I'll need them!!


    Debbie

    P.S. I am reviewing my upload.php script now and hope to post in online later for a "code review". If you wanna really help me out, please keep an eye out for it and let me know if I internalized everyone's suggestions.
    Hi Debbie,

    I will look out for you upload script and if I have anything valuable to add I will.

    ext4 has support for volumes with sizes up to 1 exabyte ( 1 exabyte = 1,048,576 terabytes ) and files with sizes up to 16 terabytes. It supports up to 64, 000 directories. Again lot's of room to grow into and you can either store your thumbnails in one directory or divide them into some logical directory structure; say by month. With the ext4 limits it gives you lots of room before you will have to move to something else.

    Running RAID 10 on ext4 and the kernel patches to move large scale deletions/updates to memory have all but wiped out the problems ext3 suffered from. The inadequacies of ext3 is why ext4 was embarked upon.

    Regards,
    Steve
    ictus==""

  7. #32
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    If you do a subfolder for every year, month, and day, that largest number of folders would be 31 (until you have your site for 32 years).

  8. #33
    SitePoint Enthusiast
    Join Date
    Dec 2011
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by samanime View Post
    If you do a subfolder for every year, month, and day, that largest number of folders would be 31 (until you have your site for 32 years).
    Not sure what you mean.
    What I had in mind is folder structure like this
    uploads/2012/02/12 <- all uploads made on Feb. 12 2012 go here.

  9. #34
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    That's what I mean.

    So, the largest number of folders in any given directory would be 31 (31 "day" folders in one month). So, until you have 32 year folders, 31 is the maximum number, which is pretty tiny.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •