tomusdrw / grunt-sync

[Not actively developed] Grunt.js task providing one-way synchronization of directories. Instead of copying all files only those that has been changed are copied which actually results in much faster execution.
MIT License
77 stars 19 forks source link

updateAndDelete does update, but not delete when destination is UNC path #18

Open chrischain opened 9 years ago

chrischain commented 9 years ago

Hello, just updated to v0.2.0 because I'm really looking forward to the destination file deletion, but so far it is not working for me. I'm wondering if it has something to do with the fact that my destination is a UNC path...

Here are the relevant parts of my gruntfile.js:

//this variable holds the target UNC path for file transfers
var devPath = '//abcdefg01/Webdev/Unit/ump.dev.company.com/ease/schedules/';

module.exports = function(grunt) {
    var rev = 1744;

    //project configuration
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        sync: {
            main: {
                files: [{
                    cwd: './',
                    src: ['**/*.cfc', '**/*.cfm', '**/*.css', '**/*.gif', '**/*.js', '**/*.png', //includes
                    '!**/gruntfile.js', '!**/DO_NOT_UPLOAD/**', '!**/node_modules/**', '!**/out/**' //excludes
                    ],
                    dest: devPath
                }],
                pretend: true,
                updateAndDelete: true,
                verbose: true
            }
        }
    });

    //load plug-ins
    grunt.loadNpmTasks('grunt-sync');

I've tried with pretend true || false, nothing seems to change.

Any help/guidance is appreciated.

tomusdrw commented 9 years ago

Do you get any verbose output when running the task? Could you try to remove trailing / in dest path? I suspect that you are running Windows. Could you try to use \ instead of / in dest path?

chrischain commented 9 years ago

You are correct about Windows.

I do get verbose output, and updates seem to be functioning normally, however I have yet to see it delete anything.

If I remove the trailing slash, it seems to perform the same as if I did not. It still does not remove files, only performs updates.

Regarding the last suggestion, I can't use backslashes because the JS parser chokes:

var devPath = '\\abcdefg01\Webdev\Unit\ump.dev.company.com\ease\schedules\
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Loading "gruntfile.js" tasks...ERROR
>> SyntaxError: Unexpected token ILLEGAL
Warning: Task "sync" not found. Use --force to continue.

Aborted due to warnings.

Thanks for looking into this!

tomusdrw commented 9 years ago

Hi! You have to escape all \ characters. Try using shorter form:

var devPath = ['', '', 'abcdefg01', 'Webdev', 'Unit', 'ump.dev.company.com', 'ease', 'schedules'].join("\\");

If in verbose output you get messages that something will be deleted then changing pretend to false should actually delete the file.

If not I will look close to your configuration and see if I've missed some case in code.

chrischain commented 9 years ago

After changing the devPath to match your suggestion, it still does not indicate any delete operations will be performed, just updates.

There are at least 6 items in subfolders and one item in the root path that should be deleted.

chrischain commented 9 years ago

I did some cursory troubleshooting, and I see that the paths variable and the result array in your second pass is coming up empty.

I also see that the destPaths variable returns the promise object, but doesn't seem to contain any usable data (at least when I attempted to enumerate it).

I hope this helps.

shiraze commented 9 years ago

I also see a similar problem. I'm also on Windows and I've tried the suggested fixes without any success. Are there any items worth logging that would help determine why the delete of a file is not happening.

tomusdrw commented 9 years ago

I'm terribly sorry guys, but didn't have time yet to look at your issue. I promise to look at this in a few days.

vizo commented 9 years ago

I am running it on linux ... and it doesn't want to copy ... logs out that it's copying but it's not ... just if i put on updateAndDelete: false then it copy ....

tomusdrw commented 9 years ago

I was looking into your issues and I couldn't find anything that could help. Could you prepare minimal Gruntfile & demo to reproduce your issue?

chrischain commented 9 years ago

Any updates on this issue? Tomasz, do you need any additional information from me? I'm happy to help where I can...

tomusdrw commented 9 years ago

@chrischain I dug into your issue and it seems that it won't be working with UNC paths until it will be supported in glob (see isaacs/node-glob#74)

Let's wait until this is fixed in glob. I'll update library and we can see if it works.

@vizo @shiraze Since this thread is related to UNC path, please open new issue if you experience different problems.

shiraze commented 9 years ago

Thanks! Much appreciated

In fact, after further thought, we would rather not yet have the ability to delete files from the target location. It's a good feature for grunt-sync but not one we need.

Keep up the good work On 8 Nov 2014 12:30, "Tomasz Drwięga" notifications@github.com wrote:

@chrischain https://github.com/chrischain I dug into your issue and it seems that it won't be working with UNC paths until it will be supported in glob (see isaacs/node-glob#74 https://github.com/isaacs/node-glob/issues/74)

Let's wait until this is fixed in glob. I'll update library and we can see if it works.

@vizo https://github.com/vizo @shiraze https://github.com/shiraze Since this thread is related to UNC path, please open new issue if you experience different problems.

— Reply to this email directly or view it on GitHub https://github.com/tomusdrw/grunt-sync/issues/18#issuecomment-62256133.